* src/SDCCpeeph.c (peepHole): Fixed all leaks. Added trace support for freeing...
[fw/sdcc] / support / Util / MySystem.c
index bae66caadf99658d3b8a0a777c854994b0f0f4f4..e18646b211fa94adf5bd0cf261c5e82020f6c174 100644 (file)
 
 #include "common.h"
 #include "newalloc.h"
+#if defined(_MSC_VER)
 #include <io.h>
+#else
+#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
@@ -46,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);
@@ -62,7 +73,7 @@ my_system (const char *cmd)
          strcat (cmdLine, cmd + argsStart);
          break;
        }
-      free (cmdLine);
+      Safe_free (cmdLine);
       cmdLine = NULL;
       i++;
     }
@@ -76,7 +87,7 @@ my_system (const char *cmd)
     {
       // command found in predefined path
       e = system (cmdLine);
-      free (cmdLine);
+      Safe_free (cmdLine);
     }
   else
     {