]> diplodocus.org Git - nmh/commitdiff
Don't check mh_xcalloc() and friends for a NULL return.
authorRalph Corderoy <ralph@inputplus.co.uk>
Sun, 16 Oct 2016 16:36:03 +0000 (17:36 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Sun, 16 Oct 2016 16:36:03 +0000 (17:36 +0100)
They never return NULL.  That's their prime purpose.

20 files changed:
h/dropsbr.h
sbr/addrsbr.c
sbr/fmt_compile.c
sbr/folder_delmsgs.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 5a84ae1..685055a 100644 (file)
@@ -45,7 +45,7 @@ struct drop {
  * prototypes
  */
 int mbx_open (char *, int, uid_t, gid_t, mode_t);
  * prototypes
  */
 int mbx_open (char *, int, uid_t, gid_t, mode_t);
-int mbx_read (FILE *, long, struct drop **, int);
+int mbx_read (FILE *, long, struct drop **);
 int mbx_write(char *, int, FILE *, int, long, long, off_t, int, int);
 int mbx_copy (char *, int, int, int, int, char *, int);
 int mbx_size (int, off_t, off_t);
 int mbx_write(char *, int, FILE *, int, long, long, off_t, int, int);
 int mbx_copy (char *, int, int, int, int, char *, int);
 int mbx_size (int, off_t, off_t);
index 6bb9421..5609957 100644 (file)
@@ -145,16 +145,7 @@ getm (char *str, char *dfhost, int dftype, char *eresult, size_t eresultsize)
        dftype = LOCALHOST;
     }
 
        dftype = LOCALHOST;
     }
 
-    mp = (struct mailname *) mh_xcalloc ((size_t) 1, sizeof(*mp));
-    if (mp == NULL) {
-       if (eresult) {
-           strncpy (eresult, "insufficient memory to represent address",
-                    eresultsize);
-           eresult[eresultsize - 1] = '\0';
-       }
-       return NULL;
-    }
-
+    mp = mh_xcalloc(1, sizeof *mp);
     mp->m_next = NULL;
     mp->m_text = getcpy (str);
     if (pers)
     mp->m_next = NULL;
     mp->m_text = getcpy (str);
     if (pers)
index b1788ab..84ef598 100644 (file)
@@ -409,11 +409,7 @@ fmt_compile(char *fstring, struct format **fmt, int reset_comptable)
      */
     i = strlen(fstring)/2 + 1;
                if (i==1) i++;
      */
     i = strlen(fstring)/2 + 1;
                if (i==1) 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");
-
+    next_fp = formatvec = mh_xcalloc(i, sizeof *next_fp);
     infunction = 0;
 
     cp = compile(format_string);
     infunction = 0;
 
     cp = compile(format_string);
index ebbca2d..4f9a300 100644 (file)
@@ -57,11 +57,7 @@ folder_delmsgs (struct msgs *mp, int unlink_msgs, int nohook)
         */
 
        if (mp->numsel + vecp + 1 > MAXARGS)
         */
 
        if (mp->numsel + vecp + 1 > MAXARGS)
-           vec = (char **) mh_xrealloc (vec,
-                                         (size_t) ((mp->numsel + vecp + 1) *
-                                                    sizeof(*vec)));
-       if (vec == NULL)
-           adios (NULL, "unable to allocate exec vector");
+           vec = mh_xrealloc(vec, (mp->numsel + vecp + 1) * sizeof *vec);
        for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
            if (is_selected (mp, msgnum) &&
                !(vec[vecp++] = strdup (m_name (msgnum))))
        for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
            if (is_selected (mp, msgnum) &&
                !(vec[vecp++] = strdup (m_name (msgnum))))
index 0b57e65..aa56f7c 100644 (file)
--- a/uip/ap.c
+++ b/uip/ap.c
@@ -155,8 +155,7 @@ process (char *arg, int length)
 
     (q = &pq)->pq_next = NULL;
     while ((cp = getname (arg))) {
 
     (q = &pq)->pq_next = NULL;
     while ((cp = getname (arg))) {
-       if ((p = (struct pqpair *) mh_xcalloc ((size_t) 1, sizeof(*p))) == NULL)
-           adios (NULL, "unable to allocate pqpair memory");
+       p = mh_xcalloc(1, sizeof *p);
        if ((mp = getm (cp, NULL, 0, error, sizeof(error))) == NULL) {
            p->pq_text = getcpy (cp);
            p->pq_error = getcpy (error);
        if ((mp = getm (cp, NULL, 0, error, sizeof(error))) == NULL) {
            p->pq_text = getcpy (cp);
            p->pq_error = getcpy (error);
index 418fb90..c156076 100644 (file)
@@ -164,10 +164,7 @@ main (int argc, char **argv)
            done (1);
     seq_setprev (mp);  /* set the previous-sequence */
 
            done (1);
     seq_setprev (mp);  /* set the previous-sequence */
 
-    smsgs = (struct smsg *)
-       mh_xcalloc ((size_t) (MAXFOLDER + 2), sizeof(*smsgs));
-    if (smsgs == NULL)
-       adios (NULL, "unable to allocate burst storage");
+    smsgs = mh_xcalloc(MAXFOLDER + 2, sizeof *smsgs);
 
     hi = mp->hghmsg + 1;
 
 
     hi = mp->hghmsg + 1;
 
index f6d67a0..0d87a06 100644 (file)
@@ -156,7 +156,7 @@ mbx_chk_mmdf (int fd)
 
 
 int
 
 
 int
-mbx_read (FILE *fp, long pos, struct drop **drops, int noisy)
+mbx_read (FILE *fp, long pos, struct drop **drops)
 {
     register int len, size;
     register long ld1, ld2;
 {
     register int len, size;
     register long ld1, ld2;
@@ -164,12 +164,8 @@ mbx_read (FILE *fp, long pos, struct drop **drops, int noisy)
     char buffer[BUFSIZ];
     register struct drop *cp, *dp, *ep, *pp;
 
     char buffer[BUFSIZ];
     register struct drop *cp, *dp, *ep, *pp;
 
-    pp = (struct drop *) mh_xcalloc ((size_t) (len = MAXFOLDER), sizeof(*dp));
-    if (pp == NULL) {
-       if (noisy)
-           admonish (NULL, "unable to allocate drop storage");
-       return NOTOK;
-    }
+    len = MAXFOLDER;
+    pp = mh_xcalloc(len, sizeof *pp);
 
     ld1 = (long) strlen (mmdlm1);
     ld2 = (long) strlen (mmdlm2);
 
     ld1 = (long) strlen (mmdlm1);
     ld2 = (long) strlen (mmdlm2);
@@ -504,12 +500,7 @@ map_read (char *file, long pos, struct drop **drops, int noisy)
     }
 
     msgp = mp->d_id;
     }
 
     msgp = mp->d_id;
-    dp = (struct drop *) mh_xcalloc ((size_t) (msgp + 1), sizeof(*dp));
-    if (dp == NULL) {
-       close (md);
-       return 0;
-    }
-
+    dp = mh_xcalloc(msgp + 1, sizeof *dp);
     memcpy((char *) dp, (char *) mp, sizeof(*dp));
 
     lseek (md, (off_t) sizeof(*mp), SEEK_SET);
     memcpy((char *) dp, (char *) mp, sizeof(*dp));
 
     lseek (md, (off_t) sizeof(*mp), SEEK_SET);
@@ -576,7 +567,7 @@ map_write (char *mailbox, int md, int id, long last, off_t start,
            return NOTOK;
        }
 
            return NOTOK;
        }
 
-       switch (i = mbx_read (fp, 0, &rp, noisy)) {
+       switch (i = mbx_read (fp, 0, &rp)) {
            case NOTOK:
                fclose (fp);
                mbx_close (file, fd);
            case NOTOK:
                fclose (fp);
                mbx_close (file, fd);
index 712d7df..40972b7 100644 (file)
@@ -420,8 +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]))) {
     for (i = 0; i < addrs->size; i++) {
        (q = &pq)->pq_next = NULL;
        while ((cp = getname(addrs->msgs[i]))) {
-           if ((p = (struct pqpair *) mh_xcalloc ((size_t) 1, sizeof(*p))) == NULL)
-               adios (NULL, "unable to allocate pqpair memory");
+           p = mh_xcalloc(1, sizeof *p);
            if ((mp = getm(cp, NULL, 0, error, sizeof(error))) == NULL) {
                p->pq_text = getcpy(cp);
                p->pq_error = getcpy(error);
            if ((mp = getm(cp, NULL, 0, error, sizeof(error))) == NULL) {
                p->pq_text = getcpy(cp);
                p->pq_error = getcpy(error);
index 3ef5022..858bfe6 100644 (file)
@@ -161,8 +161,7 @@ build_mime (char *infile, int autobuild, int dist, int directives,
     /*
      * Allocate space for primary (outside) content
      */
     /*
      * Allocate space for primary (outside) content
      */
-    if ((ct = (CT) mh_xcalloc (1, sizeof(*ct))) == NULL)
-       adios (NULL, "out of memory");
+    ct = mh_xcalloc(1, sizeof *ct);
 
     /*
      * Allocate structure for handling decoded content
 
     /*
      * Allocate structure for handling decoded content
@@ -394,8 +393,7 @@ finish_field:
     ct->c_type = CT_MULTIPART;
     ct->c_subtype = MULTI_MIXED;
 
     ct->c_type = CT_MULTIPART;
     ct->c_subtype = MULTI_MIXED;
 
-    if ((m = (struct multipart *) mh_xcalloc (1, sizeof(*m))) == NULL)
-       adios (NULL, "out of memory");
+    m = mh_xcalloc(1, sizeof *m);
     ct->c_ctparams = (void *) m;
     pp = &m->mp_parts;
 
     ct->c_ctparams = (void *) m;
     pp = &m->mp_parts;
 
@@ -414,8 +412,7 @@ finish_field:
        if (!p)
            continue;
 
        if (!p)
            continue;
 
-       if ((part = (struct part *) mh_xcalloc (1, sizeof(*part))) == NULL)
-           adios (NULL, "out of memory");
+       part = mh_xcalloc(1, sizeof *part);
        *pp = part;
        pp = &part->mp_next;
        part->mp_part = p;
        *pp = part;
        pp = &part->mp_next;
        part->mp_part = p;
@@ -435,9 +432,7 @@ finish_field:
            adios("reading", "Unable to open %s for", at_entry->filename);
        }
 
            adios("reading", "Unable to open %s for", at_entry->filename);
        }
 
-       if ((p = (CT) mh_xcalloc (1, sizeof(*p))) == NULL)
-           adios(NULL, "out of memory");
-
+       p = mh_xcalloc(1, sizeof *p);
        init_decoded_content(p, infile);
 
        /*
        init_decoded_content(p, infile);
 
        /*
@@ -448,8 +443,7 @@ finish_field:
 
        setup_attach_content(p, at_entry->filename);
 
 
        setup_attach_content(p, at_entry->filename);
 
-       if ((part = (struct part *) mh_xcalloc (1, sizeof(*part))) == NULL)
-           adios (NULL, "out of memory");
+       part = mh_xcalloc(1, sizeof *part);
        *pp = part;
        pp = &part->mp_next;
        part->mp_part = p;
        *pp = part;
        pp = &part->mp_next;
        part->mp_part = p;
@@ -474,9 +468,8 @@ finish_field:
         free (cts);
 
         /* Extract the type part (as a CT) from filename. */
         free (cts);
 
         /* Extract the type part (as a CT) from filename. */
-        if (! (cts = (CT *) mh_xcalloc ((size_t) 2, sizeof *cts))) {
-            adios (NULL, "out of memory");
-        } else if (! (cts[0] = parse_mime (convert_head->filename))) {
+        cts = mh_xcalloc(2, sizeof *cts);
+        if (! (cts[0] = parse_mime (convert_head->filename))) {
             adios (NULL, "failed to parse %s", convert_head->filename);
         }
 
             adios (NULL, "failed to parse %s", convert_head->filename);
         }
 
@@ -503,9 +496,7 @@ finish_field:
        struct part *part;
        struct text *t;
 
        struct part *part;
        struct text *t;
 
-       if ((p = (CT) mh_xcalloc (1, sizeof(*p))) == NULL)
-           adios(NULL, "out of memory");
-
+       p = mh_xcalloc(1, sizeof *p);
        init_decoded_content(p, infile);
 
        if (get_ctinfo ("text/plain", p, 0) == NOTOK)
        init_decoded_content(p, infile);
 
        if (get_ctinfo ("text/plain", p, 0) == NOTOK)
@@ -523,14 +514,11 @@ finish_field:
        p->c_begin = ftell(in);
        p->c_end = ftell(in);
 
        p->c_begin = ftell(in);
        p->c_end = ftell(in);
 
-       if ((t = (struct text *) mh_xcalloc (1, sizeof (*t))) == NULL)
-           adios (NULL, "out of memory");
-
+       t = mh_xcalloc(1, sizeof *t);
        t->tx_charset = CHARSET_SPECIFIED;
        p->c_ctparams = t;
 
        t->tx_charset = CHARSET_SPECIFIED;
        p->c_ctparams = t;
 
-       if ((part = (struct part *) mh_xcalloc (1, sizeof(*part))) == NULL)
-           adios (NULL, "out of memory");
+       part = mh_xcalloc(1, sizeof *part);
        *pp = part;
        part->mp_part = p;
     }
        *pp = part;
        part->mp_part = p;
     }
@@ -677,8 +665,7 @@ user_content (FILE *in, char *buf, CT *ctp, const char *infilename)
     }
 
     /* allocate basic Content structure */
     }
 
     /* allocate basic Content structure */
-    if ((ct = (CT) mh_xcalloc (1, sizeof(*ct))) == NULL)
-       adios (NULL, "out of memory");
+    ct = mh_xcalloc(1, sizeof *ct);
     *ctp = ct;
 
     /* allocate basic structure for handling decoded content */
     *ctp = ct;
 
     /* allocate basic structure for handling decoded content */
@@ -909,8 +896,7 @@ use_forw:
             * reference, we need to create another Content structure
             * for the message/external-body to wrap it in.
             */
             * reference, we need to create another Content structure
             * for the message/external-body to wrap it in.
             */
-           if ((ct = (CT) mh_xcalloc (1, sizeof(*ct))) == NULL)
-               adios (NULL, "out of memory");
+           ct = mh_xcalloc(1, sizeof *ct);
            init_decoded_content(ct, infilename);
            *ctp = ct;
            if (get_ctinfo (buffer, ct, 0) == NOTOK)
            init_decoded_content(ct, infilename);
            *ctp = ct;
            if (get_ctinfo (buffer, ct, 0) == NOTOK)
@@ -918,8 +904,7 @@ use_forw:
            ct->c_type = CT_MESSAGE;
            ct->c_subtype = MESSAGE_EXTERNAL;
 
            ct->c_type = CT_MESSAGE;
            ct->c_subtype = MESSAGE_EXTERNAL;
 
-           if ((e = (struct exbody *) mh_xcalloc (1, sizeof(*e))) == NULL)
-               adios (NULL, "out of memory");
+           e = mh_xcalloc(1, sizeof *e);
            ct->c_ctparams = (void *) e;
 
            e->eb_parent = ct;
            ct->c_ctparams = (void *) e;
 
            e->eb_parent = ct;
@@ -1028,8 +1013,7 @@ use_forw:
            ct->c_type = CT_MULTIPART;
            ct->c_subtype = MULTI_DIGEST;
 
            ct->c_type = CT_MULTIPART;
            ct->c_subtype = MULTI_DIGEST;
 
-           if ((m = (struct multipart *) mh_xcalloc (1, sizeof(*m))) == NULL)
-               adios (NULL, "out of memory");
+           m = mh_xcalloc(1, sizeof *m);
            ct->c_ctparams = (void *) m;
            pp = &m->mp_parts;
 
            ct->c_ctparams = (void *) m;
            pp = &m->mp_parts;
 
@@ -1039,8 +1023,7 @@ use_forw:
                    CT p;
                    CE pe;
 
                    CT p;
                    CE pe;
 
-                   if ((p = (CT) mh_xcalloc (1, sizeof(*p))) == NULL)
-                       adios (NULL, "out of memory");
+                   p = mh_xcalloc(1, sizeof *p);
                    init_decoded_content (p, infilename);
                    pe = &p->c_cefile;
                    if (get_ctinfo ("message/rfc822", p, 0) == NOTOK)
                    init_decoded_content (p, infilename);
                    pe = &p->c_cefile;
                    if (get_ctinfo ("message/rfc822", p, 0) == NOTOK)
@@ -1053,8 +1036,7 @@ use_forw:
                    if (listsw && stat (pe->ce_file, &st) != NOTOK)
                        p->c_end = (long) st.st_size;
 
                    if (listsw && stat (pe->ce_file, &st) != NOTOK)
                        p->c_end = (long) st.st_size;
 
-                   if ((part = (struct part *) mh_xcalloc (1, sizeof(*part))) == NULL)
-                       adios (NULL, "out of memory");
+                   part = mh_xcalloc(1, sizeof *part);
                    *pp = part;
                    pp = &part->mp_next;
                    part->mp_part = p;
                    *pp = part;
                    pp = &part->mp_next;
                    part->mp_part = p;
@@ -1114,8 +1096,7 @@ use_forw:
        ct->c_type = CT_MULTIPART;
        ct->c_subtype = vrsn;
 
        ct->c_type = CT_MULTIPART;
        ct->c_subtype = vrsn;
 
-       if ((m = (struct multipart *) mh_xcalloc (1, sizeof(*m))) == NULL)
-           adios (NULL, "out of memory");
+       m = mh_xcalloc(1, sizeof *m);
        ct->c_ctparams = (void *) m;
 
        pp = &m->mp_parts;
        ct->c_ctparams = (void *) m;
 
        pp = &m->mp_parts;
@@ -1131,8 +1112,7 @@ use_forw:
            if (!p)
                continue;
 
            if (!p)
                continue;
 
-           if ((part = (struct part *) mh_xcalloc (1, sizeof(*part))) == NULL)
-               adios (NULL, "out of memory");
+           part = mh_xcalloc(1, sizeof *part);
            *pp = part;
            pp = &part->mp_next;
            part->mp_part = p;
            *pp = part;
            pp = &part->mp_next;
            part->mp_part = p;
@@ -2104,11 +2084,7 @@ set_charset (CT ct, int contains8bit) {
         struct text *t;
 
         if (ct->c_ctparams == NULL) {
         struct text *t;
 
         if (ct->c_ctparams == NULL) {
-            if ((t = ct->c_ctparams =
-                 (struct text *) mh_xcalloc (1, sizeof (struct text))) ==
-                NULL) {
-                adios (NULL, "out of memory");
-            }
+            t = ct->c_ctparams = mh_xcalloc(1, sizeof *t);
             t->tx_charset = CHARSET_UNSPECIFIED;
         } else {
             t = (struct text *) ct->c_ctparams;
             t->tx_charset = CHARSET_UNSPECIFIED;
         } else {
             t = (struct text *) ct->c_ctparams;
index 6195b31..4cccbad 100644 (file)
@@ -358,9 +358,7 @@ main (int argc, char **argv) {
             }
         }
 
             }
         }
 
-        if (! (cts = (CT *) mh_xcalloc ((size_t) 2, sizeof *cts))) {
-            adios (NULL, "out of memory");
-        }
+        cts = mh_xcalloc(2, sizeof *cts);
         ctp = cts;
 
         if ((ct = parse_mime (file))) {
         ctp = cts;
 
         if ((ct = parse_mime (file))) {
@@ -415,10 +413,7 @@ main (int argc, char **argv) {
             }
         seq_setprev (mp);       /* set the previous-sequence */
 
             }
         seq_setprev (mp);       /* set the previous-sequence */
 
-        if (! (cts =
-               (CT *) mh_xcalloc ((size_t) (mp->numsel + 1), sizeof *cts))) {
-            adios (NULL, "out of memory");
-        }
+        cts = mh_xcalloc(mp->numsel + 1, sizeof *cts);
         ctp = cts;
 
         for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
         ctp = cts;
 
         for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
@@ -1506,9 +1501,7 @@ static CT
 divide_part (CT ct) {
     CT new_part;
 
 divide_part (CT ct) {
     CT new_part;
 
-    if ((new_part = (CT) mh_xcalloc (1, sizeof *new_part)) == NULL)
-        adios (NULL, "out of memory");
-
+    new_part = mh_xcalloc(1, sizeof *new_part);
     /* Just copy over what is needed for decoding.  c_vrsn and
        c_celine aren't necessary. */
     new_part->c_file = add (ct->c_file, NULL);
     /* Just copy over what is needed for decoding.  c_vrsn and
        c_celine aren't necessary. */
     new_part->c_file = add (ct->c_file, NULL);
@@ -1663,8 +1656,7 @@ build_multipart_alt (CT first_alt, CT new_part, int type, int subtype) {
     struct multipart *m;
     const struct str2init *ctinit;
 
     struct multipart *m;
     const struct str2init *ctinit;
 
-    if ((ct = (CT) mh_xcalloc (1, sizeof *ct)) == NULL)
-        adios (NULL, "out of memory");
+    ct = mh_xcalloc(1, sizeof *ct);
 
     /* Set up the multipart/alternative part.  These fields of *ct were
        initialized to 0 by mh_xcalloc():
 
     /* Set up the multipart/alternative part.  These fields of *ct were
        initialized to 0 by mh_xcalloc():
@@ -1771,9 +1763,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;
 
     p->mp_next->mp_next = NULL;
     p->mp_next->mp_part = first_alt;
 
-    if ((m = (struct multipart *) mh_xcalloc (1, sizeof (struct multipart))) ==
-        NULL)
-        adios (NULL, "out of memory");
+    m = mh_xcalloc(1, sizeof *m);
     m->mp_start = concat (boundary, "\n", NULL);
     m->mp_stop = concat (boundary, "--\n", NULL);
     m->mp_parts = p;
     m->mp_start = concat (boundary, "\n", NULL);
     m->mp_stop = concat (boundary, "--\n", NULL);
     m->mp_parts = p;
@@ -2729,9 +2719,7 @@ set_text_ctparams(CT ct, char *decodetypes, int lf_line_endings) {
     default:
         if (should_decode(decodetypes, ct->c_ctinfo.ci_type, ct->c_ctinfo.ci_subtype)) {
             if (ct->c_ctparams == NULL) {
     default:
         if (should_decode(decodetypes, ct->c_ctinfo.ci_type, ct->c_ctinfo.ci_subtype)) {
             if (ct->c_ctparams == NULL) {
-                if ((ct->c_ctparams = (struct text *) mh_xcalloc (1, sizeof (struct text))) == NULL) {
-                    adios (NULL, "out of memory");
-                }
+                ct->c_ctparams = mh_xcalloc(1, sizeof (struct text));
             }
             ((struct text *) ct->c_ctparams)->lf_line_endings = lf_line_endings;
         }
             }
             ((struct text *) ct->c_ctparams)->lf_line_endings = lf_line_endings;
         }
index 3465523..1ef0b6e 100644 (file)
@@ -266,8 +266,7 @@ do_cache:
      * check if message is coming from file
      */
     if (file) {
      * check if message is coming from file
      */
     if (file) {
-       if (!(cts = (CT *) mh_xcalloc ((size_t) 2, sizeof(*cts))))
-           adios (NULL, "out of memory");
+       cts = mh_xcalloc(2, sizeof *cts);
        ctp = cts;
 
        if ((ct = parse_mime (file)))
        ctp = cts;
 
        if ((ct = parse_mime (file)))
@@ -299,8 +298,7 @@ do_cache:
                done (1);
        seq_setprev (mp);       /* set the previous-sequence */
 
                done (1);
        seq_setprev (mp);       /* set the previous-sequence */
 
-       if (!(cts = (CT *) mh_xcalloc ((size_t) (mp->numsel + 1), sizeof(*cts))))
-           adios (NULL, "out of memory");
+       cts = mh_xcalloc(mp->numsel + 1, sizeof *cts);
        ctp = cts;
 
        for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
        ctp = cts;
 
        for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
index 9a35a81..6cca758 100644 (file)
@@ -1188,18 +1188,15 @@ mcomp_format (struct mcomp *c1, struct mcomp *c2)
 
     (q = &pq)->pq_next = NULL;
     while ((cp = getname (ap))) {
 
     (q = &pq)->pq_next = NULL;
     while ((cp = getname (ap))) {
-       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) {
-               p->pq_text = getcpy (cp);
-               p->pq_error = getcpy (error);
-           } else {
-               p->pq_text = getcpy (mp->m_text);
-               mnfree (mp);
-           }
-           q = (q->pq_next = p);
-       }
+       p = mh_xcalloc(1, sizeof *p);
+        if ((mp = getm (cp, NULL, 0, error, sizeof(error))) == NULL) {
+            p->pq_text = getcpy (cp);
+            p->pq_error = getcpy (error);
+        } else {
+            p->pq_text = getcpy (mp->m_text);
+            mnfree (mp);
+        }
+        q = (q->pq_next = p);
     }
 
     for (p = pq.pq_next; p; p = q) {
     }
 
     for (p = pq.pq_next; p; p = q) {
@@ -1244,22 +1241,19 @@ add_queue (struct mcomp **head, struct mcomp **tail, char *name, char *text, int
 {
     struct mcomp *c1;
 
 {
     struct mcomp *c1;
 
-    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;
-       if ((c1->c_name = name ? getcpy (name) : NULL))
-           c1->c_flags |= mcomp_flags (c1->c_name);
-       c1->c_text = text ? getcpy (text) : NULL;
-       if (flags & INIT) {
-           if (global.c_ovtxt)
-               c1->c_ovtxt = getcpy (global.c_ovtxt);
-           c1->c_offset = global.c_offset;
-           c1->c_ovoff = global. c_ovoff;
-           c1->c_width = c1->c_length = 0;
-           c1->c_cwidth = global.c_cwidth;
-           c1->c_flags |= global.c_flags & GFLAGS;
-       }
+    c1 = mh_xcalloc(1, sizeof *c1);
+    c1->c_flags = flags & ~INIT;
+    if ((c1->c_name = name ? getcpy (name) : NULL))
+        c1->c_flags |= mcomp_flags (c1->c_name);
+    c1->c_text = text ? getcpy (text) : NULL;
+    if (flags & INIT) {
+        if (global.c_ovtxt)
+            c1->c_ovtxt = getcpy (global.c_ovtxt);
+        c1->c_offset = global.c_offset;
+        c1->c_ovoff = global. c_ovoff;
+        c1->c_width = c1->c_length = 0;
+        c1->c_cwidth = global.c_cwidth;
+        c1->c_flags |= global.c_flags & GFLAGS;
     }
     if (*head == NULL)
        *head = c1;
     }
     if (*head == NULL)
        *head = c1;
index 1a70b7a..45ed007 100644 (file)
--- a/uip/mhn.c
+++ b/uip/mhn.c
@@ -440,8 +440,7 @@ do_cache:
      * check if message is coming from file
      */
     if (file) {
      * check if message is coming from file
      */
     if (file) {
-       if (!(cts = (CT *) mh_xcalloc ((size_t) 2, sizeof(*cts))))
-           adios (NULL, "out of memory");
+       cts = mh_xcalloc(2, sizeof *cts);
        ctp = cts;
 
        if ((ct = parse_mime (file)))
        ctp = cts;
 
        if ((ct = parse_mime (file)))
@@ -473,8 +472,7 @@ do_cache:
                done (1);
        seq_setprev (mp);       /* set the previous-sequence */
 
                done (1);
        seq_setprev (mp);       /* set the previous-sequence */
 
-       if (!(cts = (CT *) mh_xcalloc ((size_t) (mp->numsel + 1), sizeof(*cts))))
-           adios (NULL, "out of memory");
+       cts = mh_xcalloc(mp->numsel + 1, sizeof *cts);
        ctp = cts;
 
        for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
        ctp = cts;
 
        for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
index 40fe61d..7e539c3 100644 (file)
@@ -294,9 +294,7 @@ get_content (FILE *in, char *file, int toplevel)
     m_getfld_state_t gstate = 0;
 
     /* allocate the content structure */
     m_getfld_state_t gstate = 0;
 
     /* allocate the content structure */
-    if (!(ct = (CT) mh_xcalloc (1, sizeof(*ct))))
-       adios (NULL, "out of memory");
-
+    ct = mh_xcalloc(1, sizeof *ct);
     ct->c_fp = in;
     ct->c_file = add (file, NULL);
     ct->c_begin = ftell (ct->c_fp) + 1;
     ct->c_fp = in;
     ct->c_file = add (file, NULL);
     ct->c_begin = ftell (ct->c_fp) + 1;
@@ -1029,8 +1027,7 @@ InitText (CT ct)
     ct->c_subtype = ct_str_subtype (CT_TEXT, ci->ci_subtype);
 
     /* allocate text character set structure */
     ct->c_subtype = ct_str_subtype (CT_TEXT, ci->ci_subtype);
 
     /* allocate text character set structure */
-    if ((t = (struct text *) mh_xcalloc (1, sizeof(*t))) == NULL)
-       adios (NULL, "out of memory");
+    t = mh_xcalloc(1, sizeof *t);
     ct->c_ctparams = (void *) t;
 
     /* scan for charset parameter */
     ct->c_ctparams = (void *) t;
 
     /* scan for charset parameter */
@@ -1134,8 +1131,7 @@ InitMultiPart (CT ct)
     }
 
     /* allocate primary structure for multipart info */
     }
 
     /* allocate primary structure for multipart info */
-    if ((m = (struct multipart *) mh_xcalloc (1, sizeof(*m))) == NULL)
-       adios (NULL, "out of memory");
+    m = mh_xcalloc(1, sizeof *m);
     ct->c_ctparams = (void *) m;
 
     /* check if boundary parameter contains only whitespace characters */
     ct->c_ctparams = (void *) m;
 
     /* check if boundary parameter contains only whitespace characters */
@@ -1179,8 +1175,7 @@ InitMultiPart (CT ct)
            if (strcmp (bufp + 2, m->mp_start))
                continue;
 next_part:
            if (strcmp (bufp + 2, m->mp_start))
                continue;
 next_part:
-           if ((part = (struct part *) mh_xcalloc (1, sizeof(*part))) == NULL)
-               adios (NULL, "out of memory");
+           part = mh_xcalloc(1, sizeof *part);
            *next = part;
            next = &part->mp_next;
 
            *next = part;
            next = &part->mp_next;
 
@@ -1419,8 +1414,7 @@ InitMessage (CT ct)
                PM pm;
                struct partial *p;
 
                PM pm;
                struct partial *p;
 
-               if ((p = (struct partial *) mh_xcalloc (1, sizeof(*p))) == NULL)
-                   adios (NULL, "out of memory");
+               p = mh_xcalloc(1, sizeof *p);
                ct->c_ctparams = (void *) p;
 
                /* scan for parameters "id", "number", and "total" */
                ct->c_ctparams = (void *) p;
 
                /* scan for parameters "id", "number", and "total" */
@@ -1468,8 +1462,7 @@ invalid_param:
                CT p;
                FILE *fp;
 
                CT p;
                FILE *fp;
 
-               if ((e = (struct exbody *) mh_xcalloc (1, sizeof(*e))) == NULL)
-                   adios (NULL, "out of memory");
+               e = mh_xcalloc(1, sizeof *e);
                ct->c_ctparams = (void *) e;
 
                if (!ct->c_fp
                ct->c_ctparams = (void *) e;
 
                if (!ct->c_fp
index b2a4c0d..2405221 100644 (file)
@@ -351,8 +351,7 @@ do_cache:
      * check if message is coming from file
      */
     if (file) {
      * check if message is coming from file
      */
     if (file) {
-       if (!(cts = (CT *) mh_xcalloc ((size_t) 2, sizeof(*cts))))
-           adios (NULL, "out of memory");
+       cts = mh_xcalloc(2, sizeof *cts);
        ctp = cts;
 
        if ((ct = parse_mime (file)))
        ctp = cts;
 
        if ((ct = parse_mime (file)))
@@ -397,8 +396,7 @@ do_cache:
        seq_setprev (mp);       /* set the Previous-Sequence */
        seq_setunseen (mp, 1);  /* unset the Unseen-Sequence */
 
        seq_setprev (mp);       /* set the Previous-Sequence */
        seq_setunseen (mp, 1);  /* unset the Unseen-Sequence */
 
-       if (!(cts = (CT *) mh_xcalloc ((size_t) (mp->numsel + 1), sizeof(*cts))))
-           adios (NULL, "out of memory");
+       cts = mh_xcalloc(mp->numsel + 1, sizeof *cts);
        ctp = cts;
 
        /*
        ctp = cts;
 
        /*
index a348103..183fe7d 100644 (file)
@@ -278,8 +278,7 @@ do_cache:
      * check if message is coming from file
      */
     if (file) {
      * check if message is coming from file
      */
     if (file) {
-       if (!(cts = (CT *) mh_xcalloc ((size_t) 2, sizeof(*cts))))
-           adios (NULL, "out of memory");
+       cts = mh_xcalloc(2, sizeof *cts);
        ctp = cts;
 
        if ((ct = parse_mime (file))) {
        ctp = cts;
 
        if ((ct = parse_mime (file))) {
@@ -315,8 +314,7 @@ do_cache:
                done (1);
        seq_setprev (mp);       /* set the previous-sequence */
 
                done (1);
        seq_setprev (mp);       /* set the previous-sequence */
 
-       if (!(cts = (CT *) mh_xcalloc ((size_t) (mp->numsel + 1), sizeof(*cts))))
-           adios (NULL, "out of memory");
+       cts = mh_xcalloc(mp->numsel + 1, sizeof *cts);
        ctp = cts;
 
        for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
        ctp = cts;
 
        for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
index 62a5ba4..460eac2 100644 (file)
@@ -344,9 +344,7 @@ store_partial (CT ct, mhstoreinfo_t info)
        return NOTOK;
     }
 
        return NOTOK;
     }
 
-    if ((base = (CT *) mh_xcalloc ((size_t) (i + 1), sizeof(*base))) == NULL)
-       adios (NULL, "out of memory");
-
+    base = mh_xcalloc(i + 1, sizeof *base);
     ctq = base;
     for (ctp = info->cts; *ctp; ctp++) {
        p = *ctp;
     ctq = base;
     for (ctp = info->cts; *ctp; ctp++) {
        p = *ctp;
index 3c2107c..99d976d 100644 (file)
@@ -459,9 +459,7 @@ newnexus (int (*action)())
 {
     register struct nexus *p;
 
 {
     register struct nexus *p;
 
-    if ((p = (struct nexus *) mh_xcalloc ((size_t) 1, sizeof *p)) == NULL)
-       adios (NULL, "unable to allocate component storage");
-
+    p = mh_xcalloc(1, sizeof *p);
     p->n_action = action;
     return p;
 }
     p->n_action = action;
     return p;
 }
index 2ef32c4..804f72d 100644 (file)
@@ -126,13 +126,8 @@ scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg,
         * and it's our responsibility to free it.
         */
 
         * and it's our responsibility to free it.
         */
 
-       nxtbuf = compbuffers = (char **) mh_xcalloc ((size_t) ncomps, sizeof(char *));
-       if (nxtbuf == NULL)
-           adios (NULL, "unable to allocate component buffers");
-       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");
+       nxtbuf = compbuffers = mh_xcalloc(ncomps, sizeof *nxtbuf);
+       used_buf = mh_xcalloc(ncomps + 1, sizeof *used_buf);
        used_buf += ncomps+1; *--used_buf = 0;
        rlwidth = bodycomp && (width > SBUFSIZ)
            ? min (width, NMH_BUFSIZ)
        used_buf += ncomps+1; *--used_buf = 0;
        rlwidth = bodycomp && (width > SBUFSIZ)
            ? min (width, NMH_BUFSIZ)
@@ -326,10 +321,7 @@ finished:
        if (datecomp) {
            if (! datecomp->c_text) {
                if (datecomp->c_tws == NULL)
        if (datecomp) {
            if (! datecomp->c_text) {
                if (datecomp->c_tws == NULL)
-                   datecomp->c_tws = (struct 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 = mh_xcalloc(1, sizeof *datecomp->c_tws);
                *datecomp->c_tws = *dlocaltime ((time_t *) &st.st_mtime);
                datecomp->c_flags |= CF_DATEFAB|CF_TRUE;
            } else {
                *datecomp->c_tws = *dlocaltime ((time_t *) &st.st_mtime);
                datecomp->c_flags |= CF_DATEFAB|CF_TRUE;
            } else {
index 0b8e185..ff3f351 100644 (file)
@@ -253,9 +253,7 @@ main (int argc, char **argv)
         * the collection of messages with the same subj
         * given a message number.
         */
         * the collection of messages with the same subj
         * given a message number.
         */
-       il = (struct smsg ***) mh_xcalloc (mp->hghsel+1, sizeof(*il));
-       if (! il)
-           adios (NULL, "couldn't allocate msg list");
+       il = mh_xcalloc(mp->hghsel + 1, sizeof *il);
        for (i = 0; i < nmsgs; i++)
            il[slist[i]->s_msg] = &slist[i];
        /*
        for (i = 0; i < nmsgs; i++)
            il[slist[i]->s_msg] = &slist[i];
        /*
@@ -317,12 +315,7 @@ read_hdrs (struct msgs *mp, char *datesw)
 
     twscopy (&tb, dlocaltimenow ());
 
 
     twscopy (&tb, dlocaltimenow ());
 
-    smsgs = (struct smsg *)
-       mh_xcalloc ((size_t) (mp->hghsel - mp->lowsel + 2),
-           sizeof(*smsgs));
-    if (smsgs == NULL)
-       adios (NULL, "unable to allocate sort storage");
-
+    smsgs = mh_xcalloc(mp->hghsel - mp->lowsel + 2, sizeof *smsgs);
     s = smsgs;
     for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
        if (is_selected(mp, msgnum)) {
     s = smsgs;
     for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
        if (is_selected(mp, msgnum)) {