Replace mh_xmalloc() with mh_xcalloc()
[mmh] / sbr / utils.c
index fa4cfdb..f964e7e 100644 (file)
 #define MAXMSGS 256
 
 /*
-** Safely call malloc
-*/
-void *
-mh_xmalloc(size_t size)
-{
-       void *memory;
-
-       if (size == 0) {
-               adios(EX_SOFTWARE, NULL, "Tried to malloc 0 bytes");
-       }
-
-       memory = malloc(size);
-       if (!memory) {
-               adios(EX_OSERR, NULL, "Malloc failed");
-       }
-
-       return memory;
-}
-
-/*
 ** Safely call realloc
 */
 void *
@@ -134,7 +114,7 @@ add(char *s2, char *s1)
                len2 = strlen(s2);
        }
 
-       cp = mh_xmalloc(len1 + len2 + 1);
+       cp = mh_xcalloc(len1 + len2 + 1, sizeof(char));
 
        /* Copy s1 and free it */
        if (s1) {