Replace mh_xmalloc() with mh_xcalloc()
[mmh] / uip / scansbr.c
index ade3a28..ed163f3 100644 (file)
@@ -88,8 +88,8 @@ scan(FILE *inb, int innum, int outnum, char *fmtstr, int width, int curflg,
                                        width = MAXSCANL;
                        }
                        dat[3] = slwidth = width;
-                       scanl = (char *) mh_xmalloc((size_t) SCAN_CHARWIDTH *
-                                       (slwidth + 2));  /* probably for \n and \0 */
+                       scanl = (char *) mh_xcalloc((size_t)(slwidth + 2),
+                                       SCAN_CHARWIDTH);  /* probably for \n and \0 */
                        /* Compile format string */
                        ncomps = fmt_compile(fmtstr, &fmt) + 1;
                        FINDCOMP(datecomp, "date");
@@ -100,18 +100,14 @@ scan(FILE *inb, int innum, int outnum, char *fmtstr, int width, int curflg,
 
                nxtbuf = compbuffers = (char **) mh_xcalloc((size_t) ncomps,
                                sizeof(char *));
-               if (!nxtbuf)
-                       adios(EX_OSERR, NULL, "unable to allocate component buffers");
                used_buf = (struct comp **) mh_xcalloc((size_t) (ncomps+1),
                                sizeof(struct comp *));
-               if (!used_buf)
-                       adios(EX_OSERR, NULL, "unable to allocate component buffer stack");
                /* NULL-terminate array */
                used_buf += ncomps;
                *used_buf = NULL;
                /* allocate space for the items */
                for (i = ncomps; i--; )
-                       *nxtbuf++ = mh_xmalloc(SBUFSIZ);
+                       *nxtbuf++ = mh_xcalloc(SBUFSIZ, sizeof(char));
        }
 
        /*