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/08/12 15:37:14 UTC

svn commit: r803504 - in /commons/sandbox/runtime/trunk/src/main/native: shared/getopt.c test/testsuite.c

Author: mturk
Date: Wed Aug 12 13:37:14 2009
New Revision: 803504

URL: http://svn.apache.org/viewvc?rev=803504&view=rev
Log:
use safer x_malloc/x_free

Modified:
    commons/sandbox/runtime/trunk/src/main/native/shared/getopt.c
    commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c

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=803504&r1=803503&r2=803504&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/getopt.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/getopt.c Wed Aug 12 13:37:14 2009
@@ -495,7 +495,7 @@
     acr_getopt_t *os;
     void *avbuf;
 
-    if (!(os = calloc(1, sizeof(acr_getopt_t)))) {
+    if (!(os = x_calloc(sizeof(acr_getopt_t)))) {
         return NULL;
     }
     os->errfn   = (acr_getopt_err_fn_t *)(fprintf);
@@ -509,10 +509,10 @@
        that's the primary purpose of this function.  But people might
        want to use this function with arrays other than the main argv,
        and we shouldn't touch the caller's data.  So we copy. */
-    avbuf = malloc((argc + 1) * sizeof(const char *));
+    avbuf = x_malloc((argc + 1) * sizeof(const char *));
     if (!avbuf) {
         int saved = ACR_GET_OS_ERROR();
-        free(os);
+        x_free(os);
         ACR_SET_OS_ERROR(saved);
         return NULL;
     }

Modified: commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c?rev=803504&r1=803503&r2=803504&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c Wed Aug 12 13:37:14 2009
@@ -65,6 +65,10 @@
             "Running Apache Commons Runtime %s (%s version) test suite.\n",
             ACR_VERSION_STRING, ACR_GetLibraryBuilt());
     fflush(stdout);
+    if ((rv = ACR_Initialize(NULL)))
+        return rv;
+    if ((rv = ACR_PlatformInitialize(INVALID_HANDLE_VALUE, 0)))
+        return rv;
 
     os = ACR_GetoptInit(argc, argv, ACR_GETOPT_LONGONLY);
     if (!os) {