commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r801807 - /commons/sandbox/runtime/trunk/src/main/native/shared/string.c
Date Thu, 06 Aug 2009 20:13:16 GMT
Author: mturk
Date: Thu Aug  6 20:13:16 2009
New Revision: 801807

URL: http://svn.apache.org/viewvc?rev=801807&view=rev
Log:
Use ACR_Malloc instead malloc

Modified:
    commons/sandbox/runtime/trunk/src/main/native/shared/string.c

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=801807&r1=801806&r2=801807&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/string.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/string.c Thu Aug  6 20:13:16 2009
@@ -580,16 +580,11 @@
     char *d = NULL;
     if (s) {
         size_t size = strlen(s);
-        d = malloc(size + 1);
-        if (!d) {
-            int err = ACR_GET_OS_ERROR();
-            if (_E == NULL)
-                _E = ACR_GetJNIEnv();
-            if (_E != NULL)
-                ACR_ThrowException(_E, file, line, ACR_EX_ENOMEM, err);
+        d = ACR_Malloc(_E, file, line, size + 1);
+        if (d) {
+            memcpy(d, s, size);
+            d[size]   = '\0';
         }
-        memcpy(d, s, size);
-        d[size]   = '\0';
     }
     return d;
 }
@@ -600,16 +595,11 @@
     wchar_t *d = NULL;
     if (s) {
         size_t size = wcslen(s);
-        d = malloc((size + 1) * sizeof(wchar_t));
-        if (!d) {
-            int err = ACR_GET_OS_ERROR();
-            if (_E == NULL)
-                _E = ACR_GetJNIEnv();
-            if (_E != NULL)
-                ACR_ThrowException(_E, file, line, ACR_EX_ENOMEM, err);
+        d = ACR_Malloc(_E, file, line, (size + 1) * sizeof(wchar_t));
+        if (d) {
+            memcpy(d, s, size * sizeof(wchar_t));
+            d[size]   = L'\0';
         }
-        memcpy(d, s, size * sizeof(wchar_t));
-        d[size]   = L'\0';
     }
     return d;
 }



Mime
View raw message