From: Ralph Corderoy Date: Sun, 16 Oct 2016 16:36:03 +0000 (+0100) Subject: Don't check mh_xcalloc() and friends for a NULL return. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/8890670d4c1e8e3f9608c2850c1fe299fb256776 Don't check mh_xcalloc() and friends for a NULL return. They never return NULL. That's their prime purpose. --- diff --git a/h/dropsbr.h b/h/dropsbr.h index 5a84ae1a..685055aa 100644 --- a/h/dropsbr.h +++ b/h/dropsbr.h @@ -45,7 +45,7 @@ struct drop { * 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); diff --git a/sbr/addrsbr.c b/sbr/addrsbr.c index 6bb94211..56099574 100644 --- a/sbr/addrsbr.c +++ b/sbr/addrsbr.c @@ -145,16 +145,7 @@ getm (char *str, char *dfhost, int dftype, char *eresult, size_t eresultsize) 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) diff --git a/sbr/fmt_compile.c b/sbr/fmt_compile.c index b1788ab6..84ef5983 100644 --- a/sbr/fmt_compile.c +++ b/sbr/fmt_compile.c @@ -409,11 +409,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 *)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); diff --git a/sbr/folder_delmsgs.c b/sbr/folder_delmsgs.c index ebbca2d4..4f9a3000 100644 --- a/sbr/folder_delmsgs.c +++ b/sbr/folder_delmsgs.c @@ -57,11 +57,7 @@ folder_delmsgs (struct msgs *mp, int unlink_msgs, int nohook) */ 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)))) diff --git a/uip/ap.c b/uip/ap.c index 0b57e652..aa56f7cb 100644 --- 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))) { - 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); diff --git a/uip/burst.c b/uip/burst.c index 418fb909..c156076a 100644 --- a/uip/burst.c +++ b/uip/burst.c @@ -164,10 +164,7 @@ main (int argc, char **argv) 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; diff --git a/uip/dropsbr.c b/uip/dropsbr.c index f6d67a08..0d87a06d 100644 --- a/uip/dropsbr.c +++ b/uip/dropsbr.c @@ -156,7 +156,7 @@ mbx_chk_mmdf (int fd) 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; @@ -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; - 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); @@ -504,12 +500,7 @@ map_read (char *file, long pos, struct drop **drops, int noisy) } 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); @@ -576,7 +567,7 @@ map_write (char *mailbox, int md, int id, long last, off_t start, 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); diff --git a/uip/fmttest.c b/uip/fmttest.c index 712d7df2..40972b72 100644 --- a/uip/fmttest.c +++ b/uip/fmttest.c @@ -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]))) { - 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); diff --git a/uip/mhbuildsbr.c b/uip/mhbuildsbr.c index 3ef5022a..858bfe67 100644 --- a/uip/mhbuildsbr.c +++ b/uip/mhbuildsbr.c @@ -161,8 +161,7 @@ build_mime (char *infile, int autobuild, int dist, int directives, /* * 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 @@ -394,8 +393,7 @@ finish_field: 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; @@ -414,8 +412,7 @@ finish_field: 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; @@ -435,9 +432,7 @@ finish_field: 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); /* @@ -448,8 +443,7 @@ finish_field: 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; @@ -474,9 +468,8 @@ finish_field: 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); } @@ -503,9 +496,7 @@ finish_field: 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) @@ -523,14 +514,11 @@ finish_field: 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; - 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; } @@ -677,8 +665,7 @@ user_content (FILE *in, char *buf, CT *ctp, const char *infilename) } /* 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 */ @@ -909,8 +896,7 @@ use_forw: * 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) @@ -918,8 +904,7 @@ use_forw: 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; @@ -1028,8 +1013,7 @@ use_forw: 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; @@ -1039,8 +1023,7 @@ use_forw: 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) @@ -1053,8 +1036,7 @@ use_forw: 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; @@ -1114,8 +1096,7 @@ use_forw: 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; @@ -1131,8 +1112,7 @@ use_forw: 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; @@ -2104,11 +2084,7 @@ set_charset (CT ct, int contains8bit) { 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; diff --git a/uip/mhfixmsg.c b/uip/mhfixmsg.c index 6195b316..4cccbad4 100644 --- a/uip/mhfixmsg.c +++ b/uip/mhfixmsg.c @@ -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))) { @@ -415,10 +413,7 @@ main (int argc, char **argv) { } 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++) { @@ -1506,9 +1501,7 @@ static CT 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); @@ -1663,8 +1656,7 @@ build_multipart_alt (CT first_alt, CT new_part, int type, int subtype) { 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(): @@ -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; - 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; @@ -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) { - 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; } diff --git a/uip/mhlist.c b/uip/mhlist.c index 34655236..1ef0b6ee 100644 --- a/uip/mhlist.c +++ b/uip/mhlist.c @@ -266,8 +266,7 @@ do_cache: * 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))) @@ -299,8 +298,7 @@ do_cache: 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++) { diff --git a/uip/mhlsbr.c b/uip/mhlsbr.c index 9a35a816..6cca7580 100644 --- a/uip/mhlsbr.c +++ b/uip/mhlsbr.c @@ -1188,18 +1188,15 @@ mcomp_format (struct mcomp *c1, struct mcomp *c2) (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) { @@ -1244,22 +1241,19 @@ add_queue (struct mcomp **head, struct mcomp **tail, char *name, char *text, int { 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; diff --git a/uip/mhn.c b/uip/mhn.c index 1a70b7a4..45ed007c 100644 --- a/uip/mhn.c +++ b/uip/mhn.c @@ -440,8 +440,7 @@ do_cache: * 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))) @@ -473,8 +472,7 @@ do_cache: 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++) { diff --git a/uip/mhparse.c b/uip/mhparse.c index 40fe61d5..7e539c3a 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -294,9 +294,7 @@ get_content (FILE *in, char *file, int toplevel) 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; @@ -1029,8 +1027,7 @@ InitText (CT ct) 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 */ @@ -1134,8 +1131,7 @@ InitMultiPart (CT ct) } /* 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 */ @@ -1179,8 +1175,7 @@ InitMultiPart (CT ct) 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; @@ -1419,8 +1414,7 @@ InitMessage (CT ct) 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" */ @@ -1468,8 +1462,7 @@ invalid_param: 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 diff --git a/uip/mhshow.c b/uip/mhshow.c index b2a4c0da..24052218 100644 --- a/uip/mhshow.c +++ b/uip/mhshow.c @@ -351,8 +351,7 @@ do_cache: * 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))) @@ -397,8 +396,7 @@ do_cache: 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; /* diff --git a/uip/mhstore.c b/uip/mhstore.c index a3481034..183fe7d4 100644 --- a/uip/mhstore.c +++ b/uip/mhstore.c @@ -278,8 +278,7 @@ do_cache: * 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))) { @@ -315,8 +314,7 @@ do_cache: 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++) { diff --git a/uip/mhstoresbr.c b/uip/mhstoresbr.c index 62a5ba43..460eac28 100644 --- a/uip/mhstoresbr.c +++ b/uip/mhstoresbr.c @@ -344,9 +344,7 @@ store_partial (CT ct, mhstoreinfo_t info) 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; diff --git a/uip/picksbr.c b/uip/picksbr.c index 3c2107c2..99d976d7 100644 --- a/uip/picksbr.c +++ b/uip/picksbr.c @@ -459,9 +459,7 @@ newnexus (int (*action)()) { 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; } diff --git a/uip/scansbr.c b/uip/scansbr.c index 2ef32c4e..804f72d5 100644 --- a/uip/scansbr.c +++ b/uip/scansbr.c @@ -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. */ - 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) @@ -326,10 +321,7 @@ finished: 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 { diff --git a/uip/sortm.c b/uip/sortm.c index 0b8e1853..ff3f3519 100644 --- a/uip/sortm.c +++ b/uip/sortm.c @@ -253,9 +253,7 @@ main (int argc, char **argv) * 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]; /* @@ -317,12 +315,7 @@ read_hdrs (struct msgs *mp, char *datesw) 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)) {