You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/09/08 21:26:19 UTC

svn commit: r812657 - in /commons/sandbox/runtime/trunk/src/main/native: os/darwin/ os/hpux/ os/linux/ os/solaris/ os/unix/ os/win32/ shared/

Author: mturk
Date: Tue Sep  8 19:26:16 2009
New Revision: 812657

URL: http://svn.apache.org/viewvc?rev=812657&view=rev
Log:
Use our x_malloc/x_free wrappers everywhere. This allows custom allocators

Modified:
    commons/sandbox/runtime/trunk/src/main/native/os/darwin/group.c
    commons/sandbox/runtime/trunk/src/main/native/os/darwin/mutex.c
    commons/sandbox/runtime/trunk/src/main/native/os/darwin/user.c
    commons/sandbox/runtime/trunk/src/main/native/os/hpux/env.c
    commons/sandbox/runtime/trunk/src/main/native/os/hpux/shm.c
    commons/sandbox/runtime/trunk/src/main/native/os/linux/group.c
    commons/sandbox/runtime/trunk/src/main/native/os/linux/user.c
    commons/sandbox/runtime/trunk/src/main/native/os/solaris/env.c
    commons/sandbox/runtime/trunk/src/main/native/os/solaris/group.c
    commons/sandbox/runtime/trunk/src/main/native/os/solaris/user.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/execmem.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/ios.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/mmap.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/mutex.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/sema.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/temps.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/uutils.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/dirent.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/env.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/group.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/ios.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/mmap.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/wusec.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c
    commons/sandbox/runtime/trunk/src/main/native/shared/db.c
    commons/sandbox/runtime/trunk/src/main/native/shared/getopt.c
    commons/sandbox/runtime/trunk/src/main/native/shared/ini.c
    commons/sandbox/runtime/trunk/src/main/native/shared/md5.c
    commons/sandbox/runtime/trunk/src/main/native/shared/memory.c
    commons/sandbox/runtime/trunk/src/main/native/shared/nbb.c
    commons/sandbox/runtime/trunk/src/main/native/shared/sha1.c
    commons/sandbox/runtime/trunk/src/main/native/shared/sha2.c
    commons/sandbox/runtime/trunk/src/main/native/shared/string.c
    commons/sandbox/runtime/trunk/src/main/native/shared/tables.c
    commons/sandbox/runtime/trunk/src/main/native/shared/xdr.c

Modified: commons/sandbox/runtime/trunk/src/main/native/os/darwin/group.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/darwin/group.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/darwin/group.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/darwin/group.c Tue Sep  8 19:26:16 2009
@@ -99,7 +99,6 @@
     for (i = 0; i < n; i++) {
         x_free(gnames[i]);
     }
-    free(gnames);
+    x_free(gnames);
     return grps;
 }
-

Modified: commons/sandbox/runtime/trunk/src/main/native/os/darwin/mutex.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/darwin/mutex.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/darwin/mutex.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/darwin/mutex.c Tue Sep  8 19:26:16 2009
@@ -89,9 +89,9 @@
                 if (unlink(m->filename))
                     rc = ACR_GET_OS_ERROR();
             }
-            free((void *)(m->filename));
+            x_free((void *)(m->filename));
         }
-        free(m);
+        x_free(m);
         return rc;
     }
     return ACR_EFTYPE;
@@ -115,7 +115,7 @@
             }
             rc = ACR_SUCCESS;
         }
-        free(m);
+        x_free(m);
         return rc;
     }
     return ACR_EBADF;
@@ -174,7 +174,7 @@
         m->filename = ACR_StrdupA(_E, THROW_FMARK, fname);
         if (!m->filename) {
             rc =  ACR_GET_OS_ERROR();
-            free(m);
+            x_free(m);
             ACR_SET_OS_ERROR(rc);
             return -1;
         }
@@ -203,7 +203,7 @@
             semctl(m->filedes, 0, IPC_RMID, ick);
         }
         x_free((void *)(m->filename));
-        free(m);
+        x_free(m);
         ACR_THROW_IO_IF_ERR(rc);
         return -1;
     }
@@ -253,7 +253,7 @@
 
 finally:
     if (rc) {
-        free(m);
+        x_free(m);
         ACR_THROW_IO_IF_ERR(rc);
         return -1;
     }
@@ -449,9 +449,9 @@
                 if (unlink(m->filename))
                     rc = ACR_GET_OS_ERROR();
             }
-            free((void *)(m->filename));
+            x_free((void *)(m->filename));
         }
-        free(m);
+        x_free(m);
         return rc;
     }
     return ACR_EFTYPE;
@@ -490,8 +490,8 @@
 
 finally:
     if (rc) {
-        free((void *)(m->filename));
-        free(m);
+        x_free((void *)(m->filename));
+        x_free(m);
         ACR_THROW_IO_IF_ERR(rc);
         return -1;
     }
@@ -523,8 +523,8 @@
 
 finally:
     if (rc) {
-        free((void *)(m->filename));
-        free(m);
+        x_free((void *)(m->filename));
+        x_free(m);
         ACR_THROW_IO_IF_ERR(rc);
         return -1;
     }

Modified: commons/sandbox/runtime/trunk/src/main/native/os/darwin/user.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/darwin/user.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/darwin/user.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/darwin/user.c Tue Sep  8 19:26:16 2009
@@ -99,7 +99,7 @@
     for (i = 0; i < n; i++) {
         x_free(unames[i]);
     }
-    free(unames);
+    x_free(unames);
     return usrs;
 }
 

Modified: commons/sandbox/runtime/trunk/src/main/native/os/hpux/env.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/hpux/env.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/hpux/env.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/hpux/env.c Tue Sep  8 19:26:16 2009
@@ -35,7 +35,7 @@
         errno = EINVAL;
         return -1;
     }
-    estr = (char *)malloc(strlen(var) + strlen(val) + 2);
+    estr = (char *)x_malloc(strlen(var) + strlen(val) + 2);
     if (!estr)                /* not much we can do if no memory */
         return -1;
 
@@ -43,11 +43,11 @@
     sprintf(estr, "%s=%s", var, val);
     if (putenv(estr)) {
         int se = errno;
-        free(estr);
+        x_free(estr);
         errno = se;
         return -1;
     }
-    free(estr);
+    x_free(estr);
 
     return 0;
 }
@@ -62,7 +62,7 @@
     }
     if (getenv(var) == NULL)
         return 0;             /* no work */
-    estr = (char *)malloc(strlen(var) + 2);
+    estr = (char *)x_malloc(strlen(var) + 2);
     if (!estr)                /* not much we can do if no memory */
         return -1;
 
@@ -70,7 +70,7 @@
     sprintf(estr, "%s=", var);
     if (putenv(estr)) {
         int se = errno;
-        free(estr);
+        x_free(estr);
         errno = se;
         return -1;
     }
@@ -82,7 +82,7 @@
      * result of unsetting multiple things.
      */
     putenv(estr);
-    free(estr);
+    x_free(estr);
 
     return 0;
 }

Modified: commons/sandbox/runtime/trunk/src/main/native/os/hpux/shm.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/hpux/shm.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/hpux/shm.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/hpux/shm.c Tue Sep  8 19:26:16 2009
@@ -107,7 +107,7 @@
     }
 finally:
     x_free((void *)(m->filename));
-    free(m);
+    x_free(m);
     return rc;
 }
 
@@ -127,12 +127,12 @@
         rc = ACR_EINVAL;
     }
     else {
-        free((void *)(m->filename));
+        x_free((void *)(m->filename));
         if (m->base && shmdt(m->base) == -1) {
             rc = ACR_GET_OS_ERROR();
         }
     }
-    free(m);
+    x_free(m);
     return rc;
 }
 
@@ -251,7 +251,7 @@
         shm->usable = shm->base;
 anonerr:
         if (rc) {
-            free(shm);
+            x_free(shm);
             ACR_THROW_IO_IF_ERR(rc);
             return -1;
         }
@@ -262,7 +262,7 @@
         shm->filename = ACR_StrdupA(_E, THROW_FMARK, filename);
         if (!shm->filename) {
             rc =  ACR_GET_OS_ERROR();
-            free(shm);
+            x_free(shm);
             ACR_SET_OS_ERROR(rc);
             return -1;
         }
@@ -325,8 +325,8 @@
         if (file > 0)
             rc = close(file);
         if (rc) {
-            free((void *)(shm->filename));
-            free(shm);
+            x_free((void *)(shm->filename));
+            x_free(shm);
             ACR_THROW_IO_IF_ERR(rc);
             shm = NULL;
         }
@@ -408,8 +408,8 @@
 
 finally:
     if (rc) {
-        free((void *)(shm->filename));
-        free(shm);
+        x_free((void *)(shm->filename));
+        x_free(shm);
         ACR_THROW_IO_IF_ERR(rc);
         shm = NULL;
     }

Modified: commons/sandbox/runtime/trunk/src/main/native/os/linux/group.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/linux/group.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/linux/group.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/linux/group.c Tue Sep  8 19:26:16 2009
@@ -97,7 +97,7 @@
     for (i = 0; i < n; i++) {
         x_free(gnames[i]);
     }
-    free(gnames);
+    x_free(gnames);
     return grps;
 }
 

Modified: commons/sandbox/runtime/trunk/src/main/native/os/linux/user.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/linux/user.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/linux/user.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/linux/user.c Tue Sep  8 19:26:16 2009
@@ -97,7 +97,7 @@
     for (i = 0; i < n; i++) {
         x_free(unames[i]);
     }
-    free(unames);
+    x_free(unames);
     return usrs;
 }
 

Modified: commons/sandbox/runtime/trunk/src/main/native/os/solaris/env.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/solaris/env.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/solaris/env.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/solaris/env.c Tue Sep  8 19:26:16 2009
@@ -35,7 +35,7 @@
         errno = EINVAL;
         return -1;
     }
-    estr = (char *)malloc(strlen(var) + strlen(val) + 2);
+    estr = (char *)x_malloc(strlen(var) + strlen(val) + 2);
     if (!estr)                /* not much we can do if no memory */
         return -1;
 
@@ -43,11 +43,11 @@
     sprintf(estr, "%s=%s", var, val);
     if (putenv(estr)) {
         int se = errno;
-        free(estr);
+        x_free(estr);
         errno = se;
         return -1;
     }
-    free(estr);
+    x_free(estr);
 
     return 0;
 }
@@ -62,7 +62,7 @@
     }
     if (getenv(var) == NULL)
         return 0;             /* no work */
-    estr = (char *)malloc(strlen(var) + 2);
+    estr = (char *)x_malloc(strlen(var) + 2);
     if (!estr)                /* not much we can do if no memory */
         return -1;
 
@@ -70,7 +70,7 @@
     sprintf(estr, "%s=", var);
     if (putenv(estr)) {
         int se = errno;
-        free(estr);
+        x_free(estr);
         errno = se;
         return -1;
     }
@@ -82,7 +82,7 @@
      * result of unsetting multiple things.
      */
     putenv(estr);
-    free(estr);
+    x_free(estr);
 
     return 0;
 }

Modified: commons/sandbox/runtime/trunk/src/main/native/os/solaris/group.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/solaris/group.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/solaris/group.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/solaris/group.c Tue Sep  8 19:26:16 2009
@@ -101,7 +101,7 @@
     for (i = 0; i < n; i++) {
         x_free(gnames[i]);
     }
-    free(gnames);
+    x_free(gnames);
     return grps;
 }
 

Modified: commons/sandbox/runtime/trunk/src/main/native/os/solaris/user.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/solaris/user.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/solaris/user.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/solaris/user.c Tue Sep  8 19:26:16 2009
@@ -101,7 +101,7 @@
     for (i = 0; i < n; i++) {
         x_free(unames[i]);
     }
-    free(unames);
+    x_free(unames);
     return usrs;
 }
 

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/execmem.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/execmem.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/execmem.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/execmem.c Tue Sep  8 19:26:16 2009
@@ -44,7 +44,7 @@
 #ifdef ACR_USE_MMAP
         munmap(mem, len);
 #else
-        free(mem);
+        x_free(mem);
 #endif
         return 0;
     }
@@ -82,7 +82,7 @@
 #ifdef ACR_USE_MMAP
             munmap(mem, ass);
 #else
-            free(mem);
+            x_free(mem);
 #endif
         }
     }

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/ios.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/ios.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/ios.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/ios.c Tue Sep  8 19:26:16 2009
@@ -110,7 +110,7 @@
         return ACR_EINVAL;
     __bmp_size   = __ioh_size >> 3;
     acr_ioh_mask = __ioh_size - 1;
-    acr_ioh_tab  = (acr_ioh *)calloc(sizeof(acr_ioh), __ioh_size);
+    acr_ioh_tab  = (acr_ioh *)x_calloc(sizeof(acr_ioh) * __ioh_size);
     if (acr_ioh_tab) {
         acr_ioh_tab[acr_ioh_mask] = nul_ioh_tab;
     }
@@ -119,9 +119,9 @@
         acr_ioh_tab  = &nul_ioh_tab;
         return ACR_ENOMEM;
     }
-    __bitmap = (unsigned char *)calloc(1, __bmp_size);
+    __bitmap = (unsigned char *)x_calloc(__bmp_size);
     if (!__bitmap) {
-        free(acr_ioh_tab);
+        x_free(acr_ioh_tab);
         acr_ioh_mask = 0;
         acr_ioh_tab  = &nul_ioh_tab;
         return ACR_ENOMEM;
@@ -148,10 +148,10 @@
         return ACR_ERANGE;
     }
     nb = ns >> 3;
-    io = (acr_ioh *)calloc(sizeof(acr_ioh), ns);
+    io = (acr_ioh *)x_calloc(sizeof(acr_ioh) * ns);
     if (io) {
         memcpy(io, acr_ioh_tab, sizeof(acr_ioh) * acr_ioh_mask);
-        free(acr_ioh_tab);
+        x_free(acr_ioh_tab);
         acr_ioh_tab  = io;
         __ioh_size   = ns;
         acr_ioh_mask = ns - 1;
@@ -160,12 +160,12 @@
     }
     else
         return ACR_ENOMEM;
-    bm = (unsigned char *)calloc(1, nb);
+    bm = (unsigned char *)x_calloc(nb);
     if (!bm) {
         return ACR_ENOMEM;
     }
     memcpy(bm, __bitmap, __bmp_size);
-    free(__bitmap);
+    x_free(__bitmap);
     __bitmap   = bm;
     __bmp_size = nb;
 
@@ -286,8 +286,8 @@
                                 acr_ioh_tab[i].flags);
         }
     }
-    free(acr_ioh_tab);
-    free(__bitmap);
+    x_free(acr_ioh_tab);
+    x_free(__bitmap);
     __bitmap     = NULL;
     acr_ioh_tab  = &nul_ioh_tab;
     acr_ioh_mask = 0;

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c Tue Sep  8 19:26:16 2009
@@ -65,8 +65,7 @@
             x_free(c->data);
         x_free(c);
     }
-
-    free(t);
+    x_free(t);
 }
 
 static int initialized = 0;

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/mmap.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/mmap.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/mmap.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/mmap.c Tue Sep  8 19:26:16 2009
@@ -77,7 +77,7 @@
         if (close(m->fd))
             rc = ACR_GET_OS_ERROR();
     }
-    free(m);
+    x_free(m);
     return rc;
 }
 
@@ -222,7 +222,7 @@
     map->fd = open(filename, oflags);
     if (map->fd < 0) {
         rc =  ACR_GET_OS_ERROR();
-        free(map);
+        x_free(map);
         ACR_SET_OS_ERROR(rc);
         return -1;
     }

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/mutex.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/mutex.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/mutex.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/mutex.c Tue Sep  8 19:26:16 2009
@@ -109,9 +109,9 @@
                 if (unlink(m->filename))
                     rc = ACR_GET_OS_ERROR();
             }
-            free((void *)(m->filename));
+            x_free((void *)(m->filename));
         }
-        free(m);
+        x_free(m);
         return rc;
     }
     return ACR_EFTYPE;
@@ -135,7 +135,7 @@
             }
             rc = ACR_SUCCESS;
         }
-        free(m);
+        x_free(m);
         return rc;
     }
     return ACR_EFTYPE;
@@ -191,7 +191,7 @@
         m->filename = ACR_StrdupA(_E, THROW_FMARK, fname);
         if (!m->filename) {
             rc =  ACR_GET_OS_ERROR();
-            free(m);
+            x_free(m);
             ACR_SET_OS_ERROR(rc);
             return -1;
         }
@@ -220,7 +220,7 @@
             semctl(m->filedes, 0, IPC_RMID, ick);
         }
         x_free((void *)(m->filename));
-        free(m);
+        x_free(m);
         ACR_THROW_IO_IF_ERR(rc);
         return -1;
     }
@@ -270,7 +270,7 @@
 
 finally:
     if (rc) {
-        free(m);
+        x_free(m);
         ACR_THROW_IO_IF_ERR(rc);
         return -1;
     }
@@ -452,7 +452,7 @@
         }
         else
             rc = ACR_EBADF;
-        free(m);
+        x_free(m);
         return rc;
     }
     return ACR_EFTYPE;
@@ -507,7 +507,7 @@
 
 finally:
     if (rc) {
-        free(m);
+        x_free(m);
         ACR_THROW_IO_IF_ERR(rc);
         return -1;
     }

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/sema.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/sema.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/sema.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/sema.c Tue Sep  8 19:26:16 2009
@@ -72,7 +72,7 @@
         }
         else
             rc = ACR_EBADF;
-        free(s);
+        x_free(s);
         return rc;
     }
     return ACR_EFTYPE;
@@ -128,7 +128,7 @@
 
 finally:
     if (rc) {
-        free(s);
+        x_free(s);
         ACR_THROW_IO_IF_ERR(rc);
         return -1;
     }

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.c Tue Sep  8 19:26:16 2009
@@ -106,7 +106,7 @@
     }
 finally:
     x_free((void *)(m->filename));
-    free(m);
+    x_free(m);
     return rc;
 }
 
@@ -126,12 +126,12 @@
         rc = ACR_EINVAL;
     }
     else {
-        free((void *)(m->filename));
+        x_free((void *)(m->filename));
         if (m->base && shmdt(m->base) == -1) {
             rc = ACR_GET_OS_ERROR();
         }
     }
-    free(m);
+    x_free(m);
     return rc;
 }
 
@@ -223,7 +223,7 @@
                              MAP_ANON | MAP_SHARED, -1, 0);
         if (shm->base == (void *)MAP_FAILED) {
             rc =  ACR_GET_OS_ERROR();
-            free(shm);
+            x_free(shm);
             ACR_THROW_IO_IF_ERR(rc);
             return -1;
         }
@@ -239,7 +239,7 @@
         shm->filename = ACR_StrdupA(_E, THROW_FMARK, filename);
         if (!shm->filename) {
             rc =  ACR_GET_OS_ERROR();
-            free(shm);
+            x_free(shm);
             ACR_SET_OS_ERROR(rc);
             return -1;
         }
@@ -300,8 +300,8 @@
         if (file > 0)
             rc = close(file);
         if (rc) {
-            free((void *)(shm->filename));
-            free(shm);
+            x_free((void *)(shm->filename));
+            x_free(shm);
             ACR_THROW_IO_IF_ERR(rc);
             shm = NULL;
         }
@@ -333,7 +333,7 @@
     shm->filename = ACR_StrdupA(_E, THROW_FMARK, filename);
     if (!shm->filename) {
         rc =  ACR_GET_OS_ERROR();
-        free(shm);
+        x_free(shm);
         ACR_SET_OS_ERROR(rc);
         return -1;
     }
@@ -382,8 +382,8 @@
 
 finally:
     if (rc) {
-        free((void *)(shm->filename));
-        free(shm);
+        x_free((void *)(shm->filename));
+        x_free(shm);
         ACR_THROW_IO_IF_ERR(rc);
         shm = NULL;
     }

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/temps.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/temps.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/temps.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/temps.c Tue Sep  8 19:26:16 2009
@@ -57,14 +57,14 @@
             rc = ACR_SUCCESS;
     }
     x_free(fp->name);
-    free(fp);
+    x_free(fp);
     return rc;
 }
 
 ACR_DECLARE(int) ACR_TempFileMake(JNIEnv *_E, const char *tmpath,
                                   const char *prefix, int preserve)
 {
-    int  rc;
+    int  rc = 0;
     int  fd;
     char name[PATH_MAX] = "";
     acr_file_t *fp;
@@ -98,7 +98,6 @@
         int flags;
         if (preserve == 0)
             unlink(name);
-        rc = 0;
         if ((flags = fcntl(fd, F_GETFD)) < 0) {
             rc = errno;
         }
@@ -183,6 +182,7 @@
 {
     char  tp[PATH_MAX];
     int    f;
+
     strlcpy(tp, path, PATH_MAX);
     ACR_NO_END_SLASHA(tp);
     strlcat(tp, "/.acrXXXXXX", PATH_MAX);

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/uutils.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/uutils.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/uutils.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/uutils.c Tue Sep  8 19:26:16 2009
@@ -34,10 +34,10 @@
         size_t nr = fread(rb, 1, rd - 2, f);
         if (nr == (rd - 2)) {
             /* Try with larger buffer size */
-            char *nb = malloc(ACR_MAX_FREAD_LEN);
+            char *nb = x_malloc(ACR_MAX_FREAD_LEN);
             if (nb) {
                 memcpy(nb, rb, nr);
-                free(rb);
+                x_free(rb);
                 rb = nb;
                 rd = ACR_MAX_FREAD_LEN - nr;
                 nr += fread(rb + nr, 1, rd - 2, f);
@@ -57,7 +57,7 @@
             rb[i + 2] = '\0';
         }
         else {
-            free(rb);
+            x_free(rb);
             goto cleanup;
         }
     }

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/dirent.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/dirent.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/dirent.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/dirent.c Tue Sep  8 19:26:16 2009
@@ -56,12 +56,12 @@
         ACR_SET_OS_ERROR(ACR_ENOTDIR);
         return NULL;
     }
-    if (!(dir = malloc(sizeof(DIR))))
+    if (!(dir = x_malloc(sizeof(DIR))))
         return NULL;
 
     rc = GetFullPathNameW(wpath, ACR_HBUFF_LEN - 2, dir->d_name, NULL);
     if (rc == 0 || rc > ACR_HBUFF_LEN - 2) {
-        free(dir);
+        x_free(dir);
         /* Invalid file name */
         ACR_SET_OS_ERROR(ACR_EBADF);
         return NULL;
@@ -91,7 +91,7 @@
         if (!FindClose(dir->d_find))
             rc = GetLastError();
     }
-    free(dir);
+    x_free(dir);
     if (rc) {
         SetLastError(rc);
         return -1;

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/env.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/env.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/env.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/env.c Tue Sep  8 19:26:16 2009
@@ -136,7 +136,7 @@
         errno = EINVAL;
         return -1;
     }
-    estr = (char *)malloc(strlen(var) + strlen(val) + 2);
+    estr = (char *)x_malloc(strlen(var) + strlen(val) + 2);
     if (!estr) {
         /* not much we can do if no memory */
         ACR_SET_OS_ERROR(ACR_ENOMEM);
@@ -147,12 +147,12 @@
     sprintf(estr, "%s=%s", var, val);
     if (_msvcrt_putenv(estr)) {
         int se = errno;
-        free(estr);
+        x_free(estr);
         errno = se;
         return -1;
     }
 
-    free(estr);
+    x_free(estr);
     return 0;
 }
 
@@ -166,7 +166,7 @@
     }
     if (getenv(var) == NULL)
         return 0;             /* no work */
-    estr = (char *)malloc(strlen(var) + 2);
+    estr = (char *)x_malloc(strlen(var) + 2);
     if (!estr) {
         /* not much we can do if no memory */
         ACR_SET_OS_ERROR(ACR_ENOMEM);
@@ -177,12 +177,12 @@
     sprintf(estr, "%s=", var);
     if (_msvcrt_putenv(estr)) {
         int se = errno;
-        free(estr);
+        x_free(estr);
         errno = se;
         return -1;
     }
 
-    free(estr);
+    x_free(estr);
     return 0;
 }
 
@@ -201,7 +201,7 @@
         return -1;
     }
     elen = (wcslen(var) + wcslen(val) + 2) * sizeof(wchar_t);
-    estr = (wchar_t *)malloc(elen);
+    estr = (wchar_t *)x_malloc(elen);
     if (!estr) {
         /* not much we can do if no memory */
         ACR_SET_OS_ERROR(ACR_ENOMEM);
@@ -216,12 +216,12 @@
 #endif
     if (_msvcrt_wputenv(estr)) {
         int se = errno;
-        free(estr);
+        x_free(estr);
         errno = se;
         return -1;
     }
 
-    free(estr);
+    x_free(estr);
     return 0;
 }
 
@@ -237,7 +237,7 @@
     if (_wgetenv(var) == NULL)
         return 0;             /* no work */
     elen = (wcslen(var) + 2) * sizeof(wchar_t);
-    estr = (wchar_t *)malloc(elen);
+    estr = (wchar_t *)x_malloc(elen);
     if (!estr) {
         /* not much we can do if no memory */
         ACR_SET_OS_ERROR(ACR_ENOMEM);
@@ -251,12 +251,12 @@
 #endif
     if (_msvcrt_wputenv(estr)) {
         int se = errno;
-        free(estr);
+        x_free(estr);
         errno = se;
         return -1;
     }
 
-    free(estr);
+    x_free(estr);
     return 0;
 }
 

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c Tue Sep  8 19:26:16 2009
@@ -281,8 +281,7 @@
             ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENOTIMPL, 0);
         }
 bailout:
-        if (mpb)
-            free(mpb);
+        x_free(mpb);
     } END_WITH_WSTR(lnkname);
     } END_WITH_WSTR(target);
 
@@ -397,7 +396,7 @@
             else {
                 ex = ACR_GET_OS_ERROR();
             }
-            free(buf);
+            x_free(buf);
         }
 
     } END_WITH_WSTR(lnkname);

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/group.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/group.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/group.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/group.c Tue Sep  8 19:26:16 2009
@@ -94,7 +94,7 @@
 {
     if (t == ACR_DESC_CLOSE) {
         if (cb->dp) {
-            free(cb->dp);
+            x_free(cb->dp);
             return ACR_SUCCESS;
         }
         return ACR_EINCOMPLETE;
@@ -125,14 +125,14 @@
     if (sidtype != SidTypeGroup && sidtype != SidTypeAlias &&
         sidtype != SidTypeWellKnownGroup) {
         /* Not a group SID */
-        free(sid);
+        x_free(sid);
         return NULL;
     }
 
     gid = ACR_DescriptorCreate(_E, ACR_DT_GROUP, -1,
                                sid, sid_descriptor_handler);
     if (!gid) {
-        free(sid);
+        x_free(sid);
         return NULL;
     }
     grp = (*_E)->NewObject(_E, _clazzn.i, J4MID(0000), gid);
@@ -180,25 +180,25 @@
         return NULL;
     if (!CopySid(len, sid, id)) {
         ACR_THROW_OS_ERRNO();
-        free(sid);
+        x_free(sid);
         return NULL;
     }
     sidtype = ACR_GetAccountNameFromSid(name, MAX_PATH, sid);
     if (sidtype == -1) {
         ACR_THROW_OS_ERRNO();
-        free(sid);
+        x_free(sid);
         return NULL;
     }
     if (sidtype != SidTypeGroup && sidtype != SidTypeAlias &&
         sidtype != SidTypeWellKnownGroup) {
         /* Not a group SID */
-        free(sid);
+        x_free(sid);
         return NULL;
     }
     gid = ACR_DescriptorCreate(_E, ACR_DT_GROUP, -1,
                                sid, sid_descriptor_handler);
     if (!gid) {
-        free(sid);
+        x_free(sid);
         return NULL;
     }
     grp = (*_E)->NewObject(_E, _clazzn.i, J4MID(0000), gid);
@@ -261,7 +261,7 @@
     grp = ACR_GetTokenInformation(_E, token, TokenPrimaryGroup);
     if (grp) {
         gid = ACR_GroupObjectCreateFromId(_E, grp->PrimaryGroup);
-        free(grp);
+        x_free(grp);
     }
 
     CloseHandle(token);
@@ -285,7 +285,7 @@
         sidtype = ACR_GetAccountSidType(own->Owner);
         if (sidtype == SidTypeGroup || sidtype == SidTypeWellKnownGroup)
             gid = ACR_GroupObjectCreateFromId(_E, own->Owner);
-        free(own);
+        x_free(own);
     }
     if (!gid) {
         grp = ACR_GetTokenInformation(_E, token, TokenGroups);
@@ -303,8 +303,7 @@
         }
     }
 finally:
-    if (grp)
-        free(grp);
+    x_free(grp);
     CloseHandle(token);
     return gid;
 }

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/ios.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/ios.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/ios.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/ios.c Tue Sep  8 19:26:16 2009
@@ -85,7 +85,7 @@
         return ACR_EINVAL;
     __bmp_size   = __ioh_size >> 3;
     acr_ioh_mask = __ioh_size - 1;
-    acr_ioh_tab  = (acr_ioh *)calloc(sizeof(acr_ioh), __ioh_size);
+    acr_ioh_tab  = (acr_ioh *)x_calloc(sizeof(acr_ioh) * __ioh_size);
     if (acr_ioh_tab) {
         acr_ioh_tab[acr_ioh_mask] = nul_ioh_tab;
     }
@@ -94,9 +94,9 @@
         acr_ioh_tab  = &nul_ioh_tab;
         return ACR_ENOMEM;
     }
-    __bitmap = (unsigned char *)calloc(1, __bmp_size);
+    __bitmap = (unsigned char *)x_calloc(__bmp_size);
     if (!__bitmap) {
-        free(acr_ioh_tab);
+        x_free(acr_ioh_tab);
         acr_ioh_mask = 0;
         acr_ioh_tab  = &nul_ioh_tab;
         return ACR_ENOMEM;
@@ -105,15 +105,15 @@
      */
     __bitmap[0] = 0xFF;
     __bmp_hint  = 1;
-    
+
     if (!InitializeCriticalSectionAndSpinCount(&ios_lock, ACR_SPINCOUNT)) {
-        /* 
+        /*
          * No point to continue.
          */
-        free(acr_ioh_tab);
+        x_free(acr_ioh_tab);
         acr_ioh_mask = 0;
         acr_ioh_tab  = &nul_ioh_tab;
-        free(__bitmap);
+        x_free(__bitmap);
         __bitmap = NULL;
 
         return ACR_ENOMEM;
@@ -135,10 +135,10 @@
         return ACR_ERANGE;
     }
     nb = ns >> 3;
-    io = (acr_ioh *)calloc(sizeof(acr_ioh), ns);
+    io = (acr_ioh *)x_calloc(sizeof(acr_ioh) * ns);
     if (io) {
         memcpy(io, acr_ioh_tab, sizeof(acr_ioh) * acr_ioh_mask);
-        free(acr_ioh_tab);
+        x_free(acr_ioh_tab);
         acr_ioh_tab  = io;
         __ioh_size   = ns;
         acr_ioh_mask = ns - 1;
@@ -147,12 +147,12 @@
     }
     else
         return ACR_ENOMEM;
-    bm = (unsigned char *)calloc(1, nb);
+    bm = (unsigned char *)x_calloc(nb);
     if (!bm) {
         return ACR_ENOMEM;
     }
     memcpy(bm, __bitmap, __bmp_size);
-    free(__bitmap);
+    x_free(__bitmap);
     __bitmap   = bm;
     __bmp_size = nb;
 
@@ -274,8 +274,8 @@
                                 acr_ioh_tab[i].flags);
         }
     }
-    free(acr_ioh_tab);
-    free(__bitmap);
+    x_free(acr_ioh_tab);
+    x_free(__bitmap);
     __bitmap     = NULL;
     acr_ioh_mask = 0;
     acr_ioh_tab  = &nul_ioh_tab;

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c Tue Sep  8 19:26:16 2009
@@ -237,7 +237,7 @@
         if (!*domain)
             return;
     }
-    event_key = malloc(strlen(domain) + 64);
+    event_key = x_malloc(strlen(domain) + 64);
     if (!event_key)
         return;
     lstrcpyA(event_key,
@@ -254,9 +254,8 @@
                        (LPBYTE) &ts, sizeof(DWORD));
         RegCloseKey(key);
     }
-    free(event_key);
-    if (acr_log_domain)
-        free(acr_log_domain);
+    x_free(event_key);
+    x_free(acr_log_domain);
     acr_log_domain = strdup(domain);
 }
 

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/mmap.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/mmap.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/mmap.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/mmap.c Tue Sep  8 19:26:16 2009
@@ -74,7 +74,7 @@
         if (!CloseHandle(m->fd))
             rc = ACR_GET_OS_ERROR();
     }
-    free(m);
+    x_free(m);
     return rc;
 }
 
@@ -184,7 +184,7 @@
     map->mh = CreateFileMappingW(map->fd, NULL, prot, 0, 0, NULL);
     if (IS_INVALID_HANDLE(map->mh)) {
         rc = ACR_GET_OS_ERROR();
-        free(map);
+        x_free(map);
         ACR_SET_OS_ERROR(rc);
         return -1;
     }
@@ -235,7 +235,7 @@
                           NULL);
     if (IS_INVALID_HANDLE(map->fd)) {
         rc = ACR_GET_OS_ERROR();
-        free(map);
+        x_free(map);
         ACR_SET_OS_ERROR(rc);
         return -1;
     }
@@ -243,7 +243,7 @@
     if (IS_INVALID_HANDLE(map->mh)) {
         rc = ACR_GET_OS_ERROR();
         CloseHandle(map->fd);
-        free(map);
+        x_free(map);
         ACR_SET_OS_ERROR(rc);
         return -1;
     }

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c Tue Sep  8 19:26:16 2009
@@ -103,7 +103,7 @@
          * memory segments attached to it.
          */
         DeleteFileW(m->filename);
-        free((void *)(m->filename));
+        x_free((void *)(m->filename));
     }
     x_free(m);
     return rc;

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c Tue Sep  8 19:26:16 2009
@@ -107,7 +107,7 @@
 {
     if (t == ACR_DESC_CLOSE) {
         if (cb->dp) {
-            free(cb->dp);
+            x_free(cb->dp);
             return ACR_SUCCESS;
         }
         return ACR_EINCOMPLETE;
@@ -139,14 +139,14 @@
     }
     if (sidtype != SidTypeUser && sidtype != SidTypeAlias) {
         /* Not a user SID */
-        free(sid);
+        x_free(sid);
         return NULL;
     }
 
     uid = ACR_DescriptorCreate(_E, ACR_DT_USER, -1,
                                sid, sid_descriptor_handler);
     if (!uid) {
-        free(sid);
+        x_free(sid);
         return NULL;
     }
     usr = (*_E)->NewObject(_E, _clazzn.i, J4MID(0000), uid);
@@ -207,25 +207,25 @@
         return NULL;
     if (!CopySid(len, sid, id)) {
         ACR_THROW_OS_ERRNO();
-        free(sid);
+        x_free(sid);
         return NULL;
     }
     sidtype = ACR_GetAccountNameFromSid(name, MAX_PATH, sid);
     if (sidtype == -1) {
         ACR_THROW_OS_ERRNO();
-        free(sid);
+        x_free(sid);
         return NULL;
     }
     if (sidtype != SidTypeUser && sidtype != SidTypeAlias) {
         /* Not a user SID */
-        free(sid);
+        x_free(sid);
         return NULL;
     }
 
     uid = ACR_DescriptorCreate(_E, ACR_DT_USER, -1,
                                sid, sid_descriptor_handler);
     if (!uid) {
-        free(sid);
+        x_free(sid);
         return NULL;
     }
     usr = (*_E)->NewObject(_E, _clazzn.i, J4MID(0000), uid);
@@ -295,7 +295,7 @@
     usr = ACR_GetTokenInformation(_E, token, TokenUser);
     if (usr) {
         uid = ACR_UserObjectCreateFromId(_E, usr->User.Sid);
-        free(usr);
+        x_free(usr);
     }
 
     CloseHandle(token);
@@ -317,7 +317,7 @@
         SID_NAME_USE sidtype = ACR_GetAccountSidType(usr->Owner);
         if (sidtype == SidTypeUser)
             uid = ACR_UserObjectCreateFromId(_E, usr->Owner);
-        free(usr);
+        x_free(usr);
     }
 
     CloseHandle(token);

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/wusec.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/wusec.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/wusec.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/wusec.c Tue Sep  8 19:26:16 2009
@@ -38,14 +38,14 @@
     if (sidlen) {
         /* Give it back on the second pass with proper sidlen
          */
-        if (!(sid = malloc(sidlen))) {
+        if (!(sid = x_malloc(sidlen))) {
             ACR_SET_OS_ERROR(ACR_ENOMEM);
             return NULL;
         }
         domlen = MAX_PATH;
         if (!LookupAccountNameW(NULL, name, sid, &sidlen,
                                 domain, &domlen, sidtype)) {
-            free(sid);
+            x_free(sid);
             sid = NULL;
         }
     }
@@ -115,7 +115,7 @@
         if(_E) {
             ACR_ThrowException(_E, THROW_NMARK, ACR_EX_OSERR, rc);
         }
-        free(rv);
+        x_free(rv);
         ACR_SET_OS_ERROR(rc);
         rv = NULL;
     }
@@ -160,6 +160,7 @@
 {
     HANDLE token = NULL;
     DWORD  rc;
+
     if (!OpenThreadToken(GetCurrentThread(),
                          TOKEN_QUERY | TOKEN_QUERY_SOURCE,
                          TRUE, &token)) {

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c Tue Sep  8 19:26:16 2009
@@ -217,13 +217,13 @@
             ACR_SET_OS_ERROR(ACR_EILSEQ);
         return NULL;
     }
-    res = malloc(len * sizeof(wchar_t));
+    res = x_malloc(len * sizeof(wchar_t));
     if (!res)
         return NULL;
     if (!MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS,
                              str, -1, res, len)) {
         DWORD saved = GetLastError();
-        free(res);
+        x_free(res);
         SetLastError(saved);
         /* Update CRT errno as well */
         if (saved == ERROR_INSUFFICIENT_BUFFER)
@@ -256,7 +256,7 @@
             errno = EILSEQ;
         return NULL;
     }
-    if (!(res = malloc(len))) {
+    if (!(res = x_malloc(len))) {
         /* Make sure GetLastError returns ENOMEM
          */
         ACR_SET_OS_ERROR(ACR_ENOMEM);
@@ -278,4 +278,3 @@
         return res;
     }
 }
-

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/db.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/db.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/db.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/db.c Tue Sep  8 19:26:16 2009
@@ -21,6 +21,7 @@
 
 #include "acr.h"
 #include "acr_private.h"
+#include "acr_arch.h"
 #include "acr_clazz.h"
 #include "acr_memory.h"
 #include "acr_pointer.h"
@@ -97,7 +98,7 @@
 static int direct_buffer_cleanup(void *mem, size_t unused)
 {
     if (mem) {
-        free(mem);
+        x_free(mem);
         return 0;
     }
     else {
@@ -124,7 +125,7 @@
                                    P2N(mem), P2N(direct_buffer_cleanup),
                                    (acr_ptr_t)len);
             if (!ptr)
-                free(mem);
+                x_free(mem);
         }
         return ptr;
     }

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/getopt.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/getopt.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/getopt.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/getopt.c Tue Sep  8 19:26:16 2009
@@ -531,8 +531,8 @@
 ACR_GetoptFree(acr_getopt_t *os)
 {
     if (os) {
-        free((void *)os->argv);
-        free(os);
+        x_free((void *)os->argv);
+        x_free(os);
     }
 }
 

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/ini.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/ini.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/ini.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/ini.c Tue Sep  8 19:26:16 2009
@@ -555,7 +555,7 @@
     /* Add what's left from the original string */
     acr_sbuf_cat(&sbuf, var_ptr);
     acr_sbuf_finish(&sbuf);
-    free(str);
+    x_free(str);
 
     str = acr_sbuf_data(&sbuf);
     return strunesc(str);

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/md5.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/md5.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/md5.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/md5.c Tue Sep  8 19:26:16 2009
@@ -291,7 +291,7 @@
     acr_md5_ctx_t context;
     acr_byte_t digest[ACR_MD5_DIGEST_LENGTH];
 
-    if (out == NULL && (out = malloc(ACR_MD5_DIGEST_STRING_LENGTH)) == NULL)
+    if (out == NULL && (out = x_malloc(ACR_MD5_DIGEST_STRING_LENGTH)) == NULL)
         return NULL;
 
     ACR_MD5Init(&context);
@@ -314,7 +314,7 @@
     acr_byte_t digest[ACR_MD5_DIGEST_LENGTH];
 
     if (out == NULL &&
-       (out = malloc(ACR_MD5_DIGEST_STRING_LENGTH * sizeof(wchar_t))) == NULL)
+       (out = x_malloc(ACR_MD5_DIGEST_STRING_LENGTH * sizeof(wchar_t))) == NULL)
         return NULL;
     ACR_MD5Init(&context);
     ACR_MD5UpdateW(&context, clear, len);
@@ -335,7 +335,7 @@
     acr_md5_ctx_t context;
     acr_byte_t digest[ACR_MD5_DIGEST_LENGTH];
 
-    if (out == NULL && (out = malloc(ACR_MD5_DIGEST_STRING_LENGTH + 4)) == NULL)
+    if (out == NULL && (out = x_malloc(ACR_MD5_DIGEST_STRING_LENGTH + 4)) == NULL)
         return NULL;
 
     ACR_MD5Init(&context);
@@ -360,7 +360,7 @@
     acr_byte_t digest[ACR_MD5_DIGEST_LENGTH];
 
     if (out == NULL &&
-       (out = malloc((ACR_MD5_DIGEST_STRING_LENGTH + 4) * sizeof(wchar_t))) == NULL)
+       (out = x_malloc((ACR_MD5_DIGEST_STRING_LENGTH + 4) * sizeof(wchar_t))) == NULL)
         return NULL;
     ACR_MD5Init(&context);
     ACR_MD5UpdateW(&context, clear, len);

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/memory.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/memory.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/memory.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/memory.c Tue Sep  8 19:26:16 2009
@@ -86,7 +86,7 @@
                                ACR_EISNULL);
     }
     else
-        free(mem);
+        x_free(mem);
 }
 
 ACR_DECLARE(acr_sbh_t *) ACR_SbhCreate(JNIEnv *_E,
@@ -151,7 +151,7 @@
             if (sbh->dyn_buff) {
                 /* Copy old dynamic slots */
                 memcpy(nd, sbh->dyn_buff, sbh->dyn_size * sizeof(void *));
-                free(sbh->dyn_buff);
+                x_free(sbh->dyn_buff);
             }
 
             sbh->dyn_buff = nd;
@@ -251,7 +251,7 @@
     ACR_SbhReset(_E, file, line, sbh);
     x_free(sbh->dyn_buff);
     if (sbh->owns)
-       free(sbh);
+       x_free(sbh);
 }
 
 ACR_DECLARE(void **) ACR_Aalloc(JNIEnv *_E, const char *file, int line,
@@ -283,8 +283,8 @@
     }
     else {
         while (*ptr != NULL)
-            free(*(ptr++));
-        free(arr);
+            x_free(*(ptr++));
+        x_free(arr);
     }
 }
 
@@ -313,7 +313,7 @@
 static int memory_pointer_cleanup(void *mem, size_t unused)
 {
     if (mem) {
-        free(mem);
+        x_free(mem);
         return 0;
     }
     else {
@@ -344,7 +344,7 @@
          */
         ptr = ACR_NewBasicPointer(_E, mem, (size_t)siz, memory_pointer_cleanup);
         if (!ptr)
-            free(mem);
+            x_free(mem);
     }
     return ptr;
 }
@@ -366,7 +366,7 @@
          */
         ptr = ACR_NewBasicPointer(_E, mem, (size_t)siz, memory_pointer_cleanup);
         if (!ptr)
-            free(mem);
+            x_free(mem);
     }
     return ptr;
 }
@@ -489,7 +489,7 @@
         /* Destroy the the memory we failed to attach
          * to the new Pointer object.
          */
-        free(dp);
+        x_free(dp);
     }
     return po;
 }

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/nbb.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/nbb.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/nbb.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/nbb.c Tue Sep  8 19:26:16 2009
@@ -21,6 +21,7 @@
 
 #include "acr.h"
 #include "acr_private.h"
+#include "acr_arch.h"
 #include "acr_clazz.h"
 #include "acr_pointer.h"
 
@@ -43,10 +44,10 @@
                            ACR_EINVALSIZ);
         return NULL;
     }
-    if ((mem = malloc(sz)) != NULL) {
+    if ((mem = x_malloc(sz)) != NULL) {
         jobject rv = (*_E)->NewDirectByteBuffer(_E, mem, (jlong)sz);
         if (rv == NULL)
-            free(mem);
+            x_free(mem);
         return rv;
     }
     else {
@@ -69,10 +70,10 @@
                            ACR_EINVALSIZ);
         return NULL;
     }
-    if ((mem = calloc(1, sz)) != NULL) {
+    if ((mem = x_calloc(sz)) != NULL) {
         jobject rv = (*_E)->NewDirectByteBuffer(_E, mem, (jlong)sz);
         if (rv == NULL)
-            free(mem);
+            x_free(mem);
         return rv;
     }
     else {
@@ -125,7 +126,7 @@
         /* calculate overall size using the default alignment */
         sz += ACR_ALIGN_DEFAULT((size_t)ia[i + off]);
     }
-    if ((mem = malloc(sz)) != NULL) {
+    if ((mem = x_malloc(sz)) != NULL) {
         size_t offset = 0;
         for (i = 0; i < len; i++) {
             size_t n = ACR_ALIGN_DEFAULT((size_t)ia[i + off]);
@@ -135,7 +136,7 @@
                 /* One of the constructors failed.
                  * The entire ByteBuffer[] array is invalid.
                  */
-                free(mem);
+                x_free(mem);
                 rv = NULL;
                 goto cleanup;
             }
@@ -144,7 +145,7 @@
                 /* One of the setters failed.
                  * The entire ByteBuffer[] array is invalid.
                  */
-                free(mem);
+                x_free(mem);
                 rv = NULL;
                 goto cleanup;
             }
@@ -206,7 +207,7 @@
         /* calculate overall size using the default alignment */
         sz += ACR_ALIGN_DEFAULT((size_t)ia[i + off]);
     }
-    if ((mem = calloc(1, sz)) != NULL) {
+    if ((mem = x_calloc(sz)) != NULL) {
         size_t offset = 0;
         for (i = 0; i < len; i++) {
             size_t n = ACR_ALIGN_DEFAULT((size_t)ia[i + off]);
@@ -216,7 +217,7 @@
                 /* One of the constructors failed.
                  * The entire ByteBuffer[] array is invalid.
                  */
-                free(mem);
+                x_free(mem);
                 rv = NULL;
                 goto cleanup;
             }
@@ -225,7 +226,7 @@
                 /* One of the setters failed.
                  * The entire ByteBuffer[] array is invalid.
                  */
-                free(mem);
+                x_free(mem);
                 rv = NULL;
                 goto cleanup;
             }
@@ -331,7 +332,7 @@
         sz += ACR_ALIGN_DEFAULT((size_t)ia[i + off]);
     }
     if (sp == NULL) {
-        if (!(sp = malloc(sz))) {
+        if (!(sp = x_malloc(sz))) {
             ACR_ThrowException(_E, THROW_FMARK, ACR_EX_ENOMEM,
                                ACR_GET_OS_ERROR());
             rv = NULL;
@@ -414,7 +415,7 @@
          * throw an exception instead.
          */
         ACR_TRY {
-            free(mem);
+            x_free(mem);
         } ACR_CATCH() {
             /* XXX: Unstable.
              * On linux this works only if MALLOC_CHECK_=1 envvar is set

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/sha1.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/sha1.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/sha1.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/sha1.c Tue Sep  8 19:26:16 2009
@@ -218,7 +218,7 @@
     acr_sha1_ctx_t context;
     acr_byte_t digest[ACR_SHA1_DIGEST_LENGTH];
 
-    if (out == NULL && (out = malloc(ACR_SHA1_DIGEST_STRING_LENGTH)) == NULL)
+    if (out == NULL && (out = x_malloc(ACR_SHA1_DIGEST_STRING_LENGTH)) == NULL)
         return NULL;
 
     ACR_SHA1Init(&context);
@@ -242,7 +242,7 @@
     acr_byte_t digest[ACR_SHA1_DIGEST_LENGTH];
 
     if (out == NULL &&
-       (out = malloc(ACR_SHA1_DIGEST_STRING_LENGTH * sizeof(wchar_t))) == NULL)
+       (out = x_malloc(ACR_SHA1_DIGEST_STRING_LENGTH * sizeof(wchar_t))) == NULL)
         return NULL;
 
     ACR_SHA1Init(&context);

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/sha2.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/sha2.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/sha2.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/sha2.c Tue Sep  8 19:26:16 2009
@@ -536,7 +536,7 @@
     acr_sha2_ctx_t context;
     acr_byte_t digest[ACR_SHA256_DIGEST_LENGTH];
 
-    if (out == NULL && (out = malloc(ACR_SHA256_DIGEST_STRING_LENGTH)) == NULL)
+    if (out == NULL && (out = x_malloc(ACR_SHA256_DIGEST_STRING_LENGTH)) == NULL)
         return NULL;
 
     ACR_SHA256Init(&context);
@@ -560,7 +560,7 @@
     acr_byte_t digest[ACR_SHA256_DIGEST_LENGTH];
 
     if (out == NULL &&
-       (out = malloc(ACR_SHA256_DIGEST_STRING_LENGTH * sizeof(wchar_t))) == NULL)
+       (out = x_malloc(ACR_SHA256_DIGEST_STRING_LENGTH * sizeof(wchar_t))) == NULL)
         return NULL;
 
     ACR_SHA256Init(&context);
@@ -865,7 +865,7 @@
     acr_sha2_ctx_t context;
     acr_byte_t digest[ACR_SHA512_DIGEST_LENGTH];
 
-    if (out == NULL && (out = malloc(ACR_SHA512_DIGEST_STRING_LENGTH)) == NULL)
+    if (out == NULL && (out = x_malloc(ACR_SHA512_DIGEST_STRING_LENGTH)) == NULL)
         return NULL;
 
     ACR_SHA512Init(&context);
@@ -889,7 +889,7 @@
     acr_byte_t digest[ACR_SHA512_DIGEST_LENGTH];
 
     if (out == NULL &&
-       (out = malloc(ACR_SHA512_DIGEST_STRING_LENGTH * sizeof(wchar_t))) == NULL)
+       (out = x_malloc(ACR_SHA512_DIGEST_STRING_LENGTH * sizeof(wchar_t))) == NULL)
         return NULL;
 
     ACR_SHA512Init(&context);

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/string.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/string.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/string.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/string.c Tue Sep  8 19:26:16 2009
@@ -16,6 +16,7 @@
 
 #include "acr.h"
 #include "acr_private.h"
+#include "acr_arch.h"
 #include "acr_string.h"
 #include "acr_memory.h"
 #include "acr_error.h"
@@ -115,7 +116,7 @@
     sr = (*_E)->GetStringCritical(_E, str, NULL);
     if (!sr) {
         if (rv != b)
-            free(rv);
+            x_free(rv);
         return NULL;
     }
     else {
@@ -385,7 +386,7 @@
     sr = (*_E)->GetStringCritical(_E, str, NULL);
     if (!sr) {
         if (rv != b)
-            free(rv);
+            x_free(rv);
         return NULL;
     }
     else {
@@ -396,7 +397,7 @@
             /* XXX: Throw some exception ?
              */
             if (rv != b)
-                free(rv);
+                x_free(rv);
             return NULL;
         }
     }
@@ -474,7 +475,7 @@
                     cc[i] = s[i];
                 }
                 rs = (*_E)->NewString(_E, cc, (jsize)l);
-                free(cc);
+                x_free(cc);
             }
         }
     }
@@ -503,7 +504,7 @@
                     rs = (*_E)->NewString(_E, cc, sl);
                 else
                     ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINVAL, ex);
-                free(cc);
+                x_free(cc);
             }
         }
     }
@@ -608,6 +609,7 @@
                                 char *p, const char *s)
 {
     char *d = NULL;
+
     if (s && *s) {
         size_t srcs = 0;
         size_t size = strlen(s);
@@ -617,7 +619,7 @@
         if (d) {
             if (p) {
                 memcpy(d, p, srcs);
-                free(p);
+                x_free(p);
             }
             memcpy(d + srcs, s, size);
             d[size + srcs] = '\0';
@@ -632,6 +634,7 @@
                                    wchar_t *p, const wchar_t *s)
 {
     wchar_t *d = NULL;
+
     if (s && *s) {
         size_t srcs = 0;
         size_t size = wcslen(s);
@@ -641,7 +644,7 @@
         if (d) {
             if (p) {
                 memcpy(d, p, srcs * sizeof(wchar_t));
-                free(p);
+                x_free(p);
             }
             memcpy(d + srcs, s, size * sizeof(wchar_t));
             d[size + srcs] = L'\0';
@@ -685,7 +688,7 @@
     if (p) {
         memcpy(cp, p, strlen(p));
         cp += strlen(p);
-        free(p);
+        x_free(p);
     }
     /* Pass two --- copy the argument strings into the result space */
     nargs = 0;
@@ -739,7 +742,7 @@
     if (p) {
         memcpy(cp, p, wcslen(p) * sizeof(wchar_t));
         cp += wcslen(p);
-        free(p);
+        x_free(p);
     }
     /* Pass two --- copy the argument strings into the result space */
     nargs = 0;
@@ -867,7 +870,7 @@
     sr = (*_E)->GetStringCritical(_E, str, NULL);
     if (!sr) {
         if (rv != b)
-            free(rv);
+            x_free(rv);
         return NULL;
     }
     else {
@@ -934,7 +937,7 @@
                     cc[i] = (jchar)s[i];
                 }
                 r = (*_E)->NewString(_E, cc, l);
-                free(cc);
+                x_free(cc);
             }
         }
 #endif

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/tables.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/tables.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/tables.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/tables.c Tue Sep  8 19:26:16 2009
@@ -54,7 +54,7 @@
         esize = 1;
     arr->elts = (char *)ACR_Malloc(_E, file, line, nelts * esize);
     if (!arr->elts) {
-        free(arr);
+        x_free(arr);
         return NULL;
     }
     arr->nalloc = nelts;
@@ -69,7 +69,7 @@
 {
     if (arr) {
         x_free(arr->elts);
-        free(arr);
+        x_free(arr);
     }
     else {
         ACR_ThrowException(_E,  file, line, ACR_EX_ENULL,
@@ -97,7 +97,7 @@
         if (!(nd = ACR_Malloc(_E, file, line, arr->esize * ns)))
             return NULL;
         memcpy(nd, arr->elts, arr->nalloc * arr->esize);
-        free(arr->elts);
+        x_free(arr->elts);
         arr->elts   = nd;
         arr->nalloc = ns;
     }
@@ -144,7 +144,7 @@
     tbl->a.elts = (char *)ACR_Malloc(_E, file, line,
                                      nelts * sizeof(table_entry_t));
     if (!tbl->a.elts) {
-        free(tbl);
+        x_free(tbl);
         return NULL;
     }
     tbl->a.nalloc = nelts;
@@ -265,9 +265,9 @@
             for (i = 0; i < tbl->a.nelts; i++) {
                 x_free(e[i].key);
             }
-            free(tbl->a.elts);
+            x_free(tbl->a.elts);
         }
-        free(tbl);
+        x_free(tbl);
     }
     else {
         ACR_ThrowException(_E, file, line, ACR_EX_ENULL,

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/xdr.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/xdr.c?rev=812657&r1=812656&r2=812657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/xdr.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/xdr.c Tue Sep  8 19:26:16 2009
@@ -45,7 +45,7 @@
 
     if (len > ACR_SIZE_T_MAX)
         return ACR_EINVAL;
-    *xdr = (acr_xdr_t *)malloc(size);
+    *xdr = (acr_xdr_t *)x_malloc(size);
     if (*xdr == NULL)
         return ACR_GET_OS_ERROR();
     (*xdr)->size = len;
@@ -263,7 +263,7 @@
     pad = XDR_PADDING(len);
 
     CHECK_FOR_OVERFLOW(len + pad + 4);
-    *str = malloc(len + 1);
+    *str = x_malloc(len + 1);
     if (*str == NULL)
         return ACR_GET_OS_ERROR();
     memcpy(*str, buff, len);