* patch #3967: Create a mh_xrealloc function to prevent mistakes when
[mmh] / uip / mark.c
index aeed866..0333722 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 #include <h/mh.h>
+#include <h/utils.h>
 
 /*
  * We allocate space for messages (msgs array)
@@ -81,8 +82,7 @@ main (int argc, char **argv)
      */
     nummsgs = 0;
     maxmsgs = MAXMSGS;
-    if (!(msgs = (char **) malloc ((size_t) (maxmsgs * sizeof(*msgs)))))
-       adios (NULL, "unable to allocate storage");
+    msgs = (char **) mh_xmalloc ((size_t) (maxmsgs * sizeof(*msgs)));
 
     /*
      * Parse arguments
@@ -159,9 +159,8 @@ main (int argc, char **argv)
             */
            if (nummsgs >= maxmsgs) {
                maxmsgs += MAXMSGS;
-               if (!(msgs = (char **) realloc (msgs,
-                                               (size_t) (maxmsgs * sizeof(*msgs)))))
-                   adios (NULL, "unable to reallocate msgs storage");
+               msgs = (char **) mh_xrealloc (msgs,
+                   (size_t) (maxmsgs * sizeof(*msgs)));
            }
            msgs[nummsgs++] = cp;
        }