* src/SDCCpeeph.c (peepHole): Fixed all leaks. Added trace support for freeing...
[fw/sdcc] / support / Util / MySystem.c
index 411b11ffd9e2a24c5426dbbb177c3f5d54674068..e18646b211fa94adf5bd0cf261c5e82020f6c174 100644 (file)
 #include <sys/stat.h>
 #endif
 
+
+#if !defined(__BORLANDC__) && !defined(_MSC_VER)
+#include <unistd.h>
+#else
+// No unistd.h in Borland C++
+extern int access (const char *, int);
 #define X_OK 1
+#endif
 
 /*!
 Call an external program with arguements
@@ -50,7 +57,7 @@ my_system (const char *cmd)
   // try to find the command in predefined path's
   while (ExePathList[i])
     {
-      cmdLine = (char *) Safe_malloc (strlen (ExePathList[i]) + strlen (cmd) + 10);
+      cmdLine = (char *) Safe_alloc (strlen (ExePathList[i]) + strlen (cmd) + 10);
       strcpy (cmdLine, ExePathList[i]);        // the path
 
       strcat (cmdLine, DIR_SEPARATOR_STRING);
@@ -66,7 +73,7 @@ my_system (const char *cmd)
          strcat (cmdLine, cmd + argsStart);
          break;
        }
-      free (cmdLine);
+      Safe_free (cmdLine);
       cmdLine = NULL;
       i++;
     }
@@ -80,7 +87,7 @@ my_system (const char *cmd)
     {
       // command found in predefined path
       e = system (cmdLine);
-      free (cmdLine);
+      Safe_free (cmdLine);
     }
   else
     {