]> diplodocus.org Git - nmh/commitdiff
Added mh_xcalloc().
authorDavid Levine <levinedl@acm.org>
Sat, 11 Oct 2014 14:22:52 +0000 (09:22 -0500)
committerDavid Levine <levinedl@acm.org>
Sat, 11 Oct 2014 14:22:52 +0000 (09:22 -0500)
21 files changed:
h/utils.h
sbr/addrsbr.c
sbr/fmt_compile.c
sbr/m_getfld.c
sbr/utils.c
uip/ap.c
uip/burst.c
uip/dropsbr.c
uip/fmttest.c
uip/mhbuildsbr.c
uip/mhfixmsg.c
uip/mhlist.c
uip/mhlsbr.c
uip/mhn.c
uip/mhparse.c
uip/mhshow.c
uip/mhstore.c
uip/mhstoresbr.c
uip/picksbr.c
uip/scansbr.c
uip/sortm.c

index 92c940de6ae8bf876c040f44c11fd794774b844e..cd696784f14365224750a4cc2c4cf3f2979d81f0 100644 (file)
--- a/h/utils.h
+++ b/h/utils.h
@@ -5,6 +5,7 @@
 
 void *mh_xmalloc(size_t);
 void *mh_xrealloc(void *, size_t);
+void *mh_xcalloc(size_t, size_t);
 char *pwd(void);
 char *add(const char *, char *);
 char *addlist(char *, const char *);
index 3028847a42478e399cf9115bbae0f3212e8d0f94..23a7cb4cbbd4d27adbfbcda813993cf3a36a126f 100644 (file)
@@ -11,6 +11,7 @@
 #include <h/addrsbr.h>
 #include <h/mf.h>
 #include <h/mts.h>
+#include <h/utils.h>
 
 /* High level parsing of addresses:
 
@@ -138,7 +139,7 @@ getm (char *str, char *dfhost, int dftype, char *eresult, size_t eresultsize)
        dftype = LOCALHOST;
     }
 
-    mp = (struct mailname *) calloc ((size_t) 1, sizeof(*mp));
+    mp = (struct mailname *) mh_xcalloc ((size_t) 1, sizeof(*mp));
     if (mp == NULL) {
        if (eresult) {
            strncpy (eresult, "insufficient memory to represent address",
index 62b27eacc512cc2539f2f82f97b2b10bff2f7d4a..9cec16a6031b784e6b1adbc66f4bbd1ed6c1101b 100644 (file)
@@ -284,7 +284,7 @@ static struct colormap colortable[] = {
 
 /* Add new component to the hash table */
 #define NEWCOMP(cm,name) do { \
-       cm = ((struct comp *) calloc(1, sizeof (struct comp)));\
+       cm = ((struct comp *) mh_xcalloc (1, sizeof (struct comp)));\
        cm->c_name = getcpy(name);\
        cm->c_refcount++;\
        ncomp++;\
@@ -406,7 +406,7 @@ fmt_compile(char *fstring, struct format **fmt, int reset_comptable)
      */
     i = strlen(fstring)/2 + 1;
                if (i==1) i++;
-    next_fp = formatvec = (struct format *)calloc ((size_t) i,
+    next_fp = formatvec = (struct format *)mh_xcalloc ((size_t) i,
                                                   sizeof(struct format));
     if (next_fp == NULL)
        adios (NULL, "unable to allocate format storage");
@@ -563,7 +563,7 @@ do_name(char *sp, int preprocess)
            CERROR("component used as both date and address");
        }
        cm->c_tws = (struct tws *)
-           calloc((size_t) 1, sizeof(*cm->c_tws));
+           mh_xcalloc ((size_t) 1, sizeof(*cm->c_tws));
        fp->f_type = preprocess;
        PUTCOMP(sp);
        cm->c_type |= CT_DATE;
index 902e9933138fb85221ae4b9d7a01b612c0b74875..b09605474e44d88d4f83970585a107dd3bfaa31d 100644 (file)
@@ -825,7 +825,7 @@ m_unknown(m_getfld_state_t *gstate, FILE *iob)
      * separator) or the last char (since the matchc would have found it
      * if it was a real delim).
      */
-    s->pat_map = (char **) calloc (256, sizeof(char *));
+    s->pat_map = (char **) mh_xcalloc (256, sizeof(char *));
 
     for (cp = s->fdelim + 1; cp < s->delimend; cp++ )
        s->pat_map[(unsigned char)*cp] = cp;
index 9dece994980ae44cea38f51e188d4af4713913a6..c6f75e07379e3c47878359c7eb88c6a4485a945f 100644 (file)
@@ -64,6 +64,24 @@ mh_xrealloc(void *ptr, size_t size)
     return memory;
 }
 
+/*
+ * Safely call calloc
+ */
+void *
+mh_xcalloc(size_t nmemb, size_t size)
+{
+    void *memory;
+
+    if (nmemb == 0  ||  size == 0)
+        adios(NULL, "Tried to calloc 0 bytes");
+
+    if ((memory = calloc(nmemb, size))) {
+        return memory;
+    } else {
+        adios(NULL, "calloc failed");
+    }
+}
+
 /*
  * Return the present working directory, if the current directory does not
  * exist, or is too long, make / the pwd.
index b231a0ebef8c4249c560fb75223b656ba9932952..b124c306c9f9ac9f9a30ebc71a498e65068354d3 100644 (file)
--- a/uip/ap.c
+++ b/uip/ap.c
@@ -11,6 +11,7 @@
 #include <h/addrsbr.h>
 #include <h/fmt_scan.h>
 #include <h/mts.h>
+#include <h/utils.h>
 
 #define        NADDRS  100
 
@@ -154,7 +155,7 @@ process (char *arg, int length)
 
     (q = &pq)->pq_next = NULL;
     while ((cp = getname (arg))) {
-       if ((p = (struct pqpair *) calloc ((size_t) 1, sizeof(*p))) == NULL)
+       if ((p = (struct pqpair *) mh_xcalloc ((size_t) 1, sizeof(*p))) == NULL)
            adios (NULL, "unable to allocate pqpair memory");
        if ((mp = getm (cp, NULL, 0, error, sizeof(error))) == NULL) {
            p->pq_text = getcpy (cp);
index 71b226c116761165021f66f44e33e9e9d1a070a1..5375f8a17233775664b868c64060e9a6f7a5cac0 100644 (file)
@@ -165,7 +165,7 @@ main (int argc, char **argv)
     seq_setprev (mp);  /* set the previous-sequence */
 
     smsgs = (struct smsg *)
-       calloc ((size_t) (MAXFOLDER + 2), sizeof(*smsgs));
+       mh_xcalloc ((size_t) (MAXFOLDER + 2), sizeof(*smsgs));
     if (smsgs == NULL)
        adios (NULL, "unable to allocate burst storage");
 
index 66edece3200c30451f5bc6881690c056ff36c724..f6d67a088c86d66743fb2a5c4b93b00bb72e9220 100644 (file)
@@ -164,7 +164,7 @@ mbx_read (FILE *fp, long pos, struct drop **drops, int noisy)
     char buffer[BUFSIZ];
     register struct drop *cp, *dp, *ep, *pp;
 
-    pp = (struct drop *) calloc ((size_t) (len = MAXFOLDER), sizeof(*dp));
+    pp = (struct drop *) mh_xcalloc ((size_t) (len = MAXFOLDER), sizeof(*dp));
     if (pp == NULL) {
        if (noisy)
            admonish (NULL, "unable to allocate drop storage");
@@ -504,7 +504,7 @@ map_read (char *file, long pos, struct drop **drops, int noisy)
     }
 
     msgp = mp->d_id;
-    dp = (struct drop *) calloc ((size_t) (msgp + 1), sizeof(*dp));
+    dp = (struct drop *) mh_xcalloc ((size_t) (msgp + 1), sizeof(*dp));
     if (dp == NULL) {
        close (md);
        return 0;
index 90df1e9e67c17fe055e1a3ed4ca36d3a079a09f7..b2d513e5402ff82d716658f601250912b152c12e 100644 (file)
@@ -420,7 +420,7 @@ process_addresses(struct format *fmt, struct msgs_array *addrs,
     for (i = 0; i < addrs->size; i++) {
        (q = &pq)->pq_next = NULL;
        while ((cp = getname(addrs->msgs[i]))) {
-           if ((p = (struct pqpair *) calloc ((size_t) 1, sizeof(*p))) == NULL)
+           if ((p = (struct pqpair *) mh_xcalloc ((size_t) 1, sizeof(*p))) == NULL)
                adios (NULL, "unable to allocate pqpair memory");
            if ((mp = getm(cp, NULL, 0, error, sizeof(error))) == NULL) {
                p->pq_text = getcpy(cp);
index 68c555d36a2cf7b64804845153092fad56708cad..2a2303855116cd385828ab57e7b73512e5a6fed5 100644 (file)
@@ -145,7 +145,7 @@ build_mime (char *infile, int autobuild, int dist, int directives,
     /*
      * Allocate space for primary (outside) content
      */
-    if ((ct = (CT) calloc (1, sizeof(*ct))) == NULL)
+    if ((ct = (CT) mh_xcalloc (1, sizeof(*ct))) == NULL)
        adios (NULL, "out of memory");
 
     /*
@@ -295,7 +295,7 @@ finish_field:
     ct->c_type = CT_MULTIPART;
     ct->c_subtype = MULTI_MIXED;
 
-    if ((m = (struct multipart *) calloc (1, sizeof(*m))) == NULL)
+    if ((m = (struct multipart *) mh_xcalloc (1, sizeof(*m))) == NULL)
        adios (NULL, "out of memory");
     ct->c_ctparams = (void *) m;
     pp = &m->mp_parts;
@@ -315,7 +315,7 @@ finish_field:
        if (!p)
            continue;
 
-       if ((part = (struct part *) calloc (1, sizeof(*part))) == NULL)
+       if ((part = (struct part *) mh_xcalloc (1, sizeof(*part))) == NULL)
            adios (NULL, "out of memory");
        *pp = part;
        pp = &part->mp_next;
@@ -336,7 +336,7 @@ finish_field:
            adios("reading", "Unable to open %s for", at_entry->filename);
        }
 
-       if ((p = (CT) calloc (1, sizeof(*p))) == NULL)
+       if ((p = (CT) mh_xcalloc (1, sizeof(*p))) == NULL)
            adios(NULL, "out of memory");
 
        init_decoded_content(p, infile);
@@ -349,7 +349,7 @@ finish_field:
 
        setup_attach_content(p, at_entry->filename);
 
-       if ((part = (struct part *) calloc (1, sizeof(*part))) == NULL)
+       if ((part = (struct part *) mh_xcalloc (1, sizeof(*part))) == NULL)
            adios (NULL, "out of memory");
        *pp = part;
        pp = &part->mp_next;
@@ -370,7 +370,7 @@ finish_field:
        struct part *part;
        struct text *t;
 
-       if ((p = (CT) calloc (1, sizeof(*p))) == NULL)
+       if ((p = (CT) mh_xcalloc (1, sizeof(*p))) == NULL)
            adios(NULL, "out of memory");
 
        init_decoded_content(p, infile);
@@ -390,13 +390,13 @@ finish_field:
        p->c_begin = ftell(in);
        p->c_end = ftell(in);
 
-       if ((t = (struct text *) calloc (1, sizeof (*t))) == NULL)
+       if ((t = (struct text *) mh_xcalloc (1, sizeof (*t))) == NULL)
            adios (NULL, "out of memory");
 
        t->tx_charset = CHARSET_SPECIFIED;
        p->c_ctparams = t;
 
-       if ((part = (struct part *) calloc (1, sizeof(*part))) == NULL)
+       if ((part = (struct part *) mh_xcalloc (1, sizeof(*part))) == NULL)
            adios (NULL, "out of memory");
        *pp = part;
        part->mp_part = p;
@@ -544,7 +544,7 @@ user_content (FILE *in, char *buf, CT *ctp, const char *infilename)
     }
 
     /* allocate basic Content structure */
-    if ((ct = (CT) calloc (1, sizeof(*ct))) == NULL)
+    if ((ct = (CT) mh_xcalloc (1, sizeof(*ct))) == NULL)
        adios (NULL, "out of memory");
     *ctp = ct;
 
@@ -776,7 +776,7 @@ use_forw:
             * reference, we need to create another Content structure
             * for the message/external-body to wrap it in.
             */
-           if ((ct = (CT) calloc (1, sizeof(*ct))) == NULL)
+           if ((ct = (CT) mh_xcalloc (1, sizeof(*ct))) == NULL)
                adios (NULL, "out of memory");
            init_decoded_content(ct, infilename);
            *ctp = ct;
@@ -785,7 +785,7 @@ use_forw:
            ct->c_type = CT_MESSAGE;
            ct->c_subtype = MESSAGE_EXTERNAL;
 
-           if ((e = (struct exbody *) calloc (1, sizeof(*e))) == NULL)
+           if ((e = (struct exbody *) mh_xcalloc (1, sizeof(*e))) == NULL)
                adios (NULL, "out of memory");
            ct->c_ctparams = (void *) e;
 
@@ -895,7 +895,7 @@ use_forw:
            ct->c_type = CT_MULTIPART;
            ct->c_subtype = MULTI_DIGEST;
 
-           if ((m = (struct multipart *) calloc (1, sizeof(*m))) == NULL)
+           if ((m = (struct multipart *) mh_xcalloc (1, sizeof(*m))) == NULL)
                adios (NULL, "out of memory");
            ct->c_ctparams = (void *) m;
            pp = &m->mp_parts;
@@ -906,7 +906,7 @@ use_forw:
                    CT p;
                    CE pe;
 
-                   if ((p = (CT) calloc (1, sizeof(*p))) == NULL)
+                   if ((p = (CT) mh_xcalloc (1, sizeof(*p))) == NULL)
                        adios (NULL, "out of memory");
                    init_decoded_content (p, infilename);
                    pe = &p->c_cefile;
@@ -920,7 +920,7 @@ use_forw:
                    if (listsw && stat (pe->ce_file, &st) != NOTOK)
                        p->c_end = (long) st.st_size;
 
-                   if ((part = (struct part *) calloc (1, sizeof(*part))) == NULL)
+                   if ((part = (struct part *) mh_xcalloc (1, sizeof(*part))) == NULL)
                        adios (NULL, "out of memory");
                    *pp = part;
                    pp = &part->mp_next;
@@ -981,7 +981,7 @@ use_forw:
        ct->c_type = CT_MULTIPART;
        ct->c_subtype = vrsn;
 
-       if ((m = (struct multipart *) calloc (1, sizeof(*m))) == NULL)
+       if ((m = (struct multipart *) mh_xcalloc (1, sizeof(*m))) == NULL)
            adios (NULL, "out of memory");
        ct->c_ctparams = (void *) m;
 
@@ -998,7 +998,7 @@ use_forw:
            if (!p)
                continue;
 
-           if ((part = (struct part *) calloc (1, sizeof(*part))) == NULL)
+           if ((part = (struct part *) mh_xcalloc (1, sizeof(*part))) == NULL)
                adios (NULL, "out of memory");
            *pp = part;
            pp = &part->mp_next;
index 4d5083c64453766798f924e5d15531d8e41fae67..491446c3033a4fc5c7e34b08f9d1156a864cbbad 100644 (file)
@@ -285,7 +285,7 @@ main (int argc, char **argv) {
             }
         }
 
-        if (! (cts = (CT *) calloc ((size_t) 2, sizeof *cts))) {
+        if (! (cts = (CT *) mh_xcalloc ((size_t) 2, sizeof *cts))) {
             adios (NULL, "out of memory");
         }
         ctp = cts;
@@ -320,7 +320,7 @@ main (int argc, char **argv) {
                 done (1);
         seq_setprev (mp);       /* set the previous-sequence */
 
-        if (! (cts = (CT *) calloc ((size_t) (mp->numsel + 1), sizeof *cts))) {
+        if (! (cts = (CT *) mh_xcalloc ((size_t) (mp->numsel + 1), sizeof *cts))) {
             adios (NULL, "out of memory");
         }
         ctp = cts;
@@ -996,7 +996,7 @@ static CT
 divide_part (CT ct) {
     CT new_part;
 
-    if ((new_part = (CT) calloc (1, sizeof *new_part)) == NULL)
+    if ((new_part = (CT) mh_xcalloc (1, sizeof *new_part)) == NULL)
         adios (NULL, "out of memory");
 
     /* Just copy over what is needed for decoding.  c_vrsn and
@@ -1148,11 +1148,11 @@ build_multipart_alt (CT first_alt, CT new_part, int type, int subtype) {
     struct multipart *m;
     const struct str2init *ctinit;
 
-    if ((ct = (CT) calloc (1, sizeof *ct)) == NULL)
+    if ((ct = (CT) mh_xcalloc (1, sizeof *ct)) == NULL)
         adios (NULL, "out of memory");
 
     /* Set up the multipart/alternative part.  These fields of *ct were
-       initialized to 0 by calloc():
+       initialized to 0 by mh_xcalloc():
        c_fp, c_unlink, c_begin, c_end,
        c_vrsn, c_ctline, c_celine,
        c_id, c_descr, c_dispo, c_partno,
@@ -1256,7 +1256,7 @@ build_multipart_alt (CT first_alt, CT new_part, int type, int subtype) {
     p->mp_next->mp_next = NULL;
     p->mp_next->mp_part = first_alt;
 
-    if ((m = (struct multipart *) calloc (1, sizeof (struct multipart))) ==
+    if ((m = (struct multipart *) mh_xcalloc (1, sizeof (struct multipart))) ==
         NULL)
         adios (NULL, "out of memory");
     m->mp_start = concat (boundary, "\n", NULL);
index f09c1475236085b9c70f78c543019fd6736667b9..91b09841cdf5099a7b01ef19abb0d1bd9e51dd5c 100644 (file)
@@ -248,7 +248,7 @@ do_cache:
      * check if message is coming from file
      */
     if (file) {
-       if (!(cts = (CT *) calloc ((size_t) 2, sizeof(*cts))))
+       if (!(cts = (CT *) mh_xcalloc ((size_t) 2, sizeof(*cts))))
            adios (NULL, "out of memory");
        ctp = cts;
 
@@ -281,7 +281,7 @@ do_cache:
                done (1);
        seq_setprev (mp);       /* set the previous-sequence */
 
-       if (!(cts = (CT *) calloc ((size_t) (mp->numsel + 1), sizeof(*cts))))
+       if (!(cts = (CT *) mh_xcalloc ((size_t) (mp->numsel + 1), sizeof(*cts))))
            adios (NULL, "out of memory");
        ctp = cts;
 
index 8d8fea17ca6a23beeccdb85bd562eb55fd2a03c2..28d489472125fd0f281e8711711223e43c3e8954 100644 (file)
@@ -778,7 +778,7 @@ evalvar (struct mcomp *c1)
            return 1;
        }
 
-       args = (struct arglist *) calloc((size_t) 1, sizeof(struct arglist));
+       args = (struct arglist *) mh_xcalloc ((size_t) 1, sizeof(struct arglist));
 
        if (arglist_tail)
            arglist_tail->a_next = args;
@@ -1184,7 +1184,7 @@ mcomp_format (struct mcomp *c1, struct mcomp *c2)
 
     (q = &pq)->pq_next = NULL;
     while ((cp = getname (ap))) {
-       if ((p = (struct pqpair *) calloc ((size_t) 1, sizeof(*p))) == NULL)
+       if ((p = (struct pqpair *) mh_xcalloc ((size_t) 1, sizeof(*p))) == NULL)
            adios (NULL, "unable to allocate pqpair memory");
        else {
            if ((mp = getm (cp, NULL, 0, error, sizeof(error))) == NULL) {
@@ -1240,7 +1240,7 @@ add_queue (struct mcomp **head, struct mcomp **tail, char *name, char *text, int
 {
     struct mcomp *c1;
 
-    if ((c1 = (struct mcomp *) calloc ((size_t) 1, sizeof(*c1))) == NULL)
+    if ((c1 = (struct mcomp *) mh_xcalloc ((size_t) 1, sizeof(*c1))) == NULL)
        adios (NULL, "unable to allocate comp memory");
     else {
        c1->c_flags = flags & ~INIT;
index 7363688f32501681a6e06a5d0fb9418c2b02b99e..1e95d41e70e96e283339099256723fb637906e6f 100644 (file)
--- a/uip/mhn.c
+++ b/uip/mhn.c
@@ -446,7 +446,7 @@ do_cache:
      * check if message is coming from file
      */
     if (file) {
-       if (!(cts = (CT *) calloc ((size_t) 2, sizeof(*cts))))
+       if (!(cts = (CT *) mh_xcalloc ((size_t) 2, sizeof(*cts))))
            adios (NULL, "out of memory");
        ctp = cts;
 
@@ -479,7 +479,7 @@ do_cache:
                done (1);
        seq_setprev (mp);       /* set the previous-sequence */
 
-       if (!(cts = (CT *) calloc ((size_t) (mp->numsel + 1), sizeof(*cts))))
+       if (!(cts = (CT *) mh_xcalloc ((size_t) (mp->numsel + 1), sizeof(*cts))))
            adios (NULL, "out of memory");
        ctp = cts;
 
index 548a9509683162dff4261ad99a4922a7d8848ac4..69bb542e7c56cca2088ef18bc3addf9eeb6db77a 100644 (file)
@@ -283,7 +283,7 @@ get_content (FILE *in, char *file, int toplevel)
     m_getfld_state_t gstate = 0;
 
     /* allocate the content structure */
-    if (!(ct = (CT) calloc (1, sizeof(*ct))))
+    if (!(ct = (CT) mh_xcalloc (1, sizeof(*ct))))
        adios (NULL, "out of memory");
 
     ct->c_fp = in;
@@ -1018,7 +1018,7 @@ InitText (CT ct)
     ct->c_subtype = kv->kv_value;
 
     /* allocate text character set structure */
-    if ((t = (struct text *) calloc (1, sizeof(*t))) == NULL)
+    if ((t = (struct text *) mh_xcalloc (1, sizeof(*t))) == NULL)
        adios (NULL, "out of memory");
     ct->c_ctparams = (void *) t;
 
@@ -1126,7 +1126,7 @@ InitMultiPart (CT ct)
     }
 
     /* allocate primary structure for multipart info */
-    if ((m = (struct multipart *) calloc (1, sizeof(*m))) == NULL)
+    if ((m = (struct multipart *) mh_xcalloc (1, sizeof(*m))) == NULL)
        adios (NULL, "out of memory");
     ct->c_ctparams = (void *) m;
 
@@ -1171,7 +1171,7 @@ InitMultiPart (CT ct)
            if (strcmp (bufp + 2, m->mp_start))
                continue;
 next_part:
-           if ((part = (struct part *) calloc (1, sizeof(*part))) == NULL)
+           if ((part = (struct part *) mh_xcalloc (1, sizeof(*part))) == NULL)
                adios (NULL, "out of memory");
            *next = part;
            next = &part->mp_next;
@@ -1354,7 +1354,7 @@ InitMessage (CT ct)
                PM pm;
                struct partial *p;
 
-               if ((p = (struct partial *) calloc (1, sizeof(*p))) == NULL)
+               if ((p = (struct partial *) mh_xcalloc (1, sizeof(*p))) == NULL)
                    adios (NULL, "out of memory");
                ct->c_ctparams = (void *) p;
 
@@ -1403,7 +1403,7 @@ invalid_param:
                CT p;
                FILE *fp;
 
-               if ((e = (struct exbody *) calloc (1, sizeof(*e))) == NULL)
+               if ((e = (struct exbody *) mh_xcalloc (1, sizeof(*e))) == NULL)
                    adios (NULL, "out of memory");
                ct->c_ctparams = (void *) e;
 
index 98cab9d148f44720b470e1940c885034dbc8bf52..0227d0c2ff798045dabd92e473998c9218c79858 100644 (file)
@@ -314,7 +314,7 @@ do_cache:
      * check if message is coming from file
      */
     if (file) {
-       if (!(cts = (CT *) calloc ((size_t) 2, sizeof(*cts))))
+       if (!(cts = (CT *) mh_xcalloc ((size_t) 2, sizeof(*cts))))
            adios (NULL, "out of memory");
        ctp = cts;
 
@@ -358,7 +358,7 @@ do_cache:
        seq_setprev (mp);       /* set the Previous-Sequence */
        seq_setunseen (mp, 1);  /* unset the Unseen-Sequence */
 
-       if (!(cts = (CT *) calloc ((size_t) (mp->numsel + 1), sizeof(*cts))))
+       if (!(cts = (CT *) mh_xcalloc ((size_t) (mp->numsel + 1), sizeof(*cts))))
            adios (NULL, "out of memory");
        ctp = cts;
 
index 72079a81662fd8f46f97fdb23196e90ba41244b5..0c91ec47559e36ed597c7833baf1153526e7c569 100644 (file)
@@ -269,7 +269,7 @@ do_cache:
      * check if message is coming from file
      */
     if (file) {
-       if (!(cts = (CT *) calloc ((size_t) 2, sizeof(*cts))))
+       if (!(cts = (CT *) mh_xcalloc ((size_t) 2, sizeof(*cts))))
            adios (NULL, "out of memory");
        ctp = cts;
 
@@ -306,7 +306,7 @@ do_cache:
                done (1);
        seq_setprev (mp);       /* set the previous-sequence */
 
-       if (!(cts = (CT *) calloc ((size_t) (mp->numsel + 1), sizeof(*cts))))
+       if (!(cts = (CT *) mh_xcalloc ((size_t) (mp->numsel + 1), sizeof(*cts))))
            adios (NULL, "out of memory");
        ctp = cts;
 
index 3ca4c7c677c0706b26f19319de0cd170e10a9b91..0ff9abf9c1d49fc6b0a05acf0a07efc472674059 100644 (file)
@@ -352,7 +352,7 @@ store_partial (CT ct, mhstoreinfo_t info)
        return NOTOK;
     }
 
-    if ((base = (CT *) calloc ((size_t) (i + 1), sizeof(*base))) == NULL)
+    if ((base = (CT *) mh_xcalloc ((size_t) (i + 1), sizeof(*base))) == NULL)
        adios (NULL, "out of memory");
 
     ctq = base;
index d444cd6853d604cc17db5d95c7c1418f896e7726..3c2107c27c0bdf2e0836e6dcd25c550026ea90c7 100644 (file)
@@ -459,7 +459,7 @@ newnexus (int (*action)())
 {
     register struct nexus *p;
 
-    if ((p = (struct nexus *) calloc ((size_t) 1, sizeof *p)) == NULL)
+    if ((p = (struct nexus *) mh_xcalloc ((size_t) 1, sizeof *p)) == NULL)
        adios (NULL, "unable to allocate component storage");
 
     p->n_action = action;
index afc090115a482bdd6553dd3ce47af3f157397b00..7391a3bd1403819095ea2530d166316e0313d9f6 100644 (file)
@@ -126,10 +126,10 @@ scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg,
         * and it's our responsibility to free it.
         */
 
-       nxtbuf = compbuffers = (char **) calloc((size_t) ncomps, sizeof(char *));
+       nxtbuf = compbuffers = (char **) mh_xcalloc ((size_t) ncomps, sizeof(char *));
        if (nxtbuf == NULL)
            adios (NULL, "unable to allocate component buffers");
-       used_buf = (struct comp **) calloc((size_t) (ncomps+1),
+       used_buf = (struct comp **) mh_xcalloc ((size_t) (ncomps+1),
            sizeof(struct comp *));
        if (used_buf == NULL)
            adios (NULL, "unable to allocate component buffer stack");
@@ -327,7 +327,7 @@ finished:
            if (! datecomp->c_text) {
                if (datecomp->c_tws == NULL)
                    datecomp->c_tws = (struct tws *)
-                       calloc((size_t) 1, sizeof(*datecomp->c_tws));
+                       mh_xcalloc ((size_t) 1, sizeof(*datecomp->c_tws));
                if (datecomp->c_tws == NULL)
                    adios (NULL, "unable to allocate tws buffer");
                *datecomp->c_tws = *dlocaltime ((time_t *) &st.st_mtime);
index 84a49394356870ee718e4453870f6bfd106c7d57..0b8e18534188e3a02932cfefc8cec1b3f2471307 100644 (file)
@@ -253,7 +253,7 @@ main (int argc, char **argv)
         * the collection of messages with the same subj
         * given a message number.
         */
-       il = (struct smsg ***) calloc (mp->hghsel+1, sizeof(*il));
+       il = (struct smsg ***) mh_xcalloc (mp->hghsel+1, sizeof(*il));
        if (! il)
            adios (NULL, "couldn't allocate msg list");
        for (i = 0; i < nmsgs; i++)
@@ -318,7 +318,7 @@ read_hdrs (struct msgs *mp, char *datesw)
     twscopy (&tb, dlocaltimenow ());
 
     smsgs = (struct smsg *)
-       calloc ((size_t) (mp->hghsel - mp->lowsel + 2),
+       mh_xcalloc ((size_t) (mp->hghsel - mp->lowsel + 2),
            sizeof(*smsgs));
     if (smsgs == NULL)
        adios (NULL, "unable to allocate sort storage");