From: David Levine Date: Sat, 11 Oct 2014 14:22:52 +0000 (-0500) Subject: Added mh_xcalloc(). X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/907c9b486942fb58b0ca330131721e074075c912?hp=fe98cae8731d52bfc3cfeef7e8ca452dea8f39ad Added mh_xcalloc(). --- diff --git a/h/utils.h b/h/utils.h index 92c940de..cd696784 100644 --- 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 *); diff --git a/sbr/addrsbr.c b/sbr/addrsbr.c index 3028847a..23a7cb4c 100644 --- a/sbr/addrsbr.c +++ b/sbr/addrsbr.c @@ -11,6 +11,7 @@ #include #include #include +#include /* 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", diff --git a/sbr/fmt_compile.c b/sbr/fmt_compile.c index 62b27eac..9cec16a6 100644 --- a/sbr/fmt_compile.c +++ b/sbr/fmt_compile.c @@ -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; diff --git a/sbr/m_getfld.c b/sbr/m_getfld.c index 902e9933..b0960547 100644 --- a/sbr/m_getfld.c +++ b/sbr/m_getfld.c @@ -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; diff --git a/sbr/utils.c b/sbr/utils.c index 9dece994..c6f75e07 100644 --- a/sbr/utils.c +++ b/sbr/utils.c @@ -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. diff --git a/uip/ap.c b/uip/ap.c index b231a0eb..b124c306 100644 --- a/uip/ap.c +++ b/uip/ap.c @@ -11,6 +11,7 @@ #include #include #include +#include #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); diff --git a/uip/burst.c b/uip/burst.c index 71b226c1..5375f8a1 100644 --- a/uip/burst.c +++ b/uip/burst.c @@ -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"); diff --git a/uip/dropsbr.c b/uip/dropsbr.c index 66edece3..f6d67a08 100644 --- a/uip/dropsbr.c +++ b/uip/dropsbr.c @@ -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; diff --git a/uip/fmttest.c b/uip/fmttest.c index 90df1e9e..b2d513e5 100644 --- a/uip/fmttest.c +++ b/uip/fmttest.c @@ -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); diff --git a/uip/mhbuildsbr.c b/uip/mhbuildsbr.c index 68c555d3..2a230385 100644 --- a/uip/mhbuildsbr.c +++ b/uip/mhbuildsbr.c @@ -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; diff --git a/uip/mhfixmsg.c b/uip/mhfixmsg.c index 4d5083c6..491446c3 100644 --- a/uip/mhfixmsg.c +++ b/uip/mhfixmsg.c @@ -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); diff --git a/uip/mhlist.c b/uip/mhlist.c index f09c1475..91b09841 100644 --- a/uip/mhlist.c +++ b/uip/mhlist.c @@ -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; diff --git a/uip/mhlsbr.c b/uip/mhlsbr.c index 8d8fea17..28d48947 100644 --- a/uip/mhlsbr.c +++ b/uip/mhlsbr.c @@ -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; diff --git a/uip/mhn.c b/uip/mhn.c index 7363688f..1e95d41e 100644 --- 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; diff --git a/uip/mhparse.c b/uip/mhparse.c index 548a9509..69bb542e 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -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; diff --git a/uip/mhshow.c b/uip/mhshow.c index 98cab9d1..0227d0c2 100644 --- a/uip/mhshow.c +++ b/uip/mhshow.c @@ -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; diff --git a/uip/mhstore.c b/uip/mhstore.c index 72079a81..0c91ec47 100644 --- a/uip/mhstore.c +++ b/uip/mhstore.c @@ -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; diff --git a/uip/mhstoresbr.c b/uip/mhstoresbr.c index 3ca4c7c6..0ff9abf9 100644 --- a/uip/mhstoresbr.c +++ b/uip/mhstoresbr.c @@ -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; diff --git a/uip/picksbr.c b/uip/picksbr.c index d444cd68..3c2107c2 100644 --- a/uip/picksbr.c +++ b/uip/picksbr.c @@ -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; diff --git a/uip/scansbr.c b/uip/scansbr.c index afc09011..7391a3bd 100644 --- a/uip/scansbr.c +++ b/uip/scansbr.c @@ -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); diff --git a/uip/sortm.c b/uip/sortm.c index 84a49394..0b8e1853 100644 --- a/uip/sortm.c +++ b/uip/sortm.c @@ -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");