From: Philipp Takacs Date: Sat, 5 Sep 2015 23:09:15 +0000 (+0200) Subject: replaced calloc with mh_xcalloc X-Git-Tag: mmh-0.2-RC1~23 X-Git-Url: http://git.marmaro.de/?p=mmh;a=commitdiff_plain;h=e16d5bfc58d8b0dfe61701cd4d6b1732e837d60a replaced calloc with mh_xcalloc This finished the work of David Levine, which was portet in the last commit. --- diff --git a/uip/mhbuild.c b/uip/mhbuild.c index de2cf45..140cfdb 100644 --- a/uip/mhbuild.c +++ b/uip/mhbuild.c @@ -329,7 +329,7 @@ build_mime(char *infile) /* ** Allocate space for primary (outside) content */ - if ((ct = (CT) calloc(1, sizeof(*ct))) == NULL) + if ((ct = (CT) mh_xcalloc(1, sizeof(*ct))) == NULL) adios(EX_OSERR, NULL, "out of memory"); /* @@ -430,7 +430,7 @@ finish_field: ct->c_subtype = MULTI_MIXED; ct->c_file = getcpy(infile); - if ((m = (struct multipart *) calloc(1, sizeof(*m))) == NULL) + if ((m = (struct multipart *) mh_xcalloc(1, sizeof(*m))) == NULL) adios(EX_OSERR, NULL, "out of memory"); ct->c_ctparams = (void *) m; pp = &m->mp_parts; @@ -450,7 +450,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(EX_OSERR, NULL, "out of memory"); *pp = part; pp = &part->mp_next; @@ -531,7 +531,7 @@ init_decoded_content(CT ct) { CE ce; - if ((ce = (CE) calloc(1, sizeof(*ce))) == NULL) + if ((ce = (CE) mh_xcalloc(1, sizeof(*ce))) == NULL) adios(EX_OSERR, NULL, "out of memory"); ct->c_cefile = ce; @@ -592,7 +592,7 @@ user_content(FILE *in, char *file, char *buf, CT *ctp) } /* allocate basic Content structure */ - if ((ct = (CT) calloc(1, sizeof(*ct))) == NULL) + if ((ct = (CT) mh_xcalloc(1, sizeof(*ct))) == NULL) adios(EX_OSERR, NULL, "out of memory"); *ctp = ct; @@ -902,7 +902,7 @@ use_forw: ct->c_subtype = MULTI_DIGEST; if ((m = (struct multipart *) - calloc(1, sizeof(*m))) == NULL) + mh_xcalloc(1, sizeof(*m))) == NULL) adios(EX_OSERR, NULL, "out of memory"); ct->c_ctparams = (void *) m; pp = &m->mp_parts; @@ -913,7 +913,7 @@ use_forw: CT p; CE pe; - if ((p = (CT) calloc(1, sizeof(*p))) + if ((p = (CT) mh_xcalloc(1, sizeof(*p))) == NULL) adios(EX_OSERR, NULL, "out of memory"); init_decoded_content(p); @@ -929,7 +929,7 @@ use_forw: msgnum); pe->ce_file = getcpy(buffer); - if ((part = (struct part *) calloc(1, sizeof(*part))) == NULL) + if ((part = (struct part *) mh_xcalloc(1, sizeof(*part))) == NULL) adios(EX_OSERR, NULL, "out of memory"); *pp = part; pp = &part->mp_next; @@ -989,7 +989,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(EX_OSERR, NULL, "out of memory"); ct->c_ctparams = (void *) m; @@ -1007,7 +1007,7 @@ use_forw: continue; if ((part = (struct part *) - calloc(1, sizeof(*part))) == NULL) + mh_xcalloc(1, sizeof(*part))) == NULL) adios(EX_OSERR, NULL, "out of memory"); *pp = part; pp = &part->mp_next; diff --git a/uip/mhl.c b/uip/mhl.c index c201a95..f3f7477 100644 --- a/uip/mhl.c +++ b/uip/mhl.c @@ -781,7 +781,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) + mh_xcalloc((size_t) 1, sizeof(*p))) == NULL) adios(EX_OSERR, NULL, "unable to allocate pqpair memory"); if ((mp = getm(cp, NULL, 0, AD_NAME, error)) == NULL) { @@ -829,7 +829,7 @@ add_queue(struct mcomp **head, struct mcomp **tail, char *name, { 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(EX_OSERR, NULL, "unable to allocate comp memory"); c1->c_flags = flags & ~INIT; diff --git a/uip/mhstore.c b/uip/mhstore.c index 2a0ddf9..1202fcb 100644 --- a/uip/mhstore.c +++ b/uip/mhstore.c @@ -570,7 +570,7 @@ store_partial(CT ct) 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(EX_OSERR, NULL, "out of memory"); ctq = base; diff --git a/uip/mhtest.c b/uip/mhtest.c index 5b47f22..43fde0e 100644 --- a/uip/mhtest.c +++ b/uip/mhtest.c @@ -209,7 +209,7 @@ main(int argc, char **argv) ** 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(EX_OSERR, NULL, "out of memory"); ctp = cts; @@ -242,7 +242,7 @@ main(int argc, char **argv) exit(EX_USAGE); seq_setprev(mp); /* set the previous-sequence */ - if (!(cts = (CT *) calloc((size_t) (mp->numsel + 1), + if (!(cts = (CT *) mh_xcalloc((size_t) (mp->numsel + 1), sizeof(*cts)))) adios(EX_OSERR, NULL, "out of memory"); ctp = cts; diff --git a/uip/pick.c b/uip/pick.c index b3bac28..819d81a 100644 --- a/uip/pick.c +++ b/uip/pick.c @@ -768,7 +768,7 @@ newnexus(int (*action)()) { 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(EX_OSERR, NULL, "unable to allocate component storage"); p->n_action = action; diff --git a/uip/rcvdist.c b/uip/rcvdist.c index 89bb1dc..1337c89 100644 --- a/uip/rcvdist.c +++ b/uip/rcvdist.c @@ -171,11 +171,11 @@ rcvdistout(FILE *inb, char *form, char *addrs) format_len = strlen(cp); ncomps = fmt_compile(cp, &fmt) + 1; if (!(nxtbuf = compbuffers = - (char **) calloc((size_t) ncomps, sizeof(char *)))) { + (char **) mh_xcalloc((size_t) ncomps, sizeof(char *)))) { adios(EX_OSERR, NULL, "unable to allocate component buffers"); } if (!(savecomp = used_buf = - (struct comp **) calloc((size_t) (ncomps + 1), + (struct comp **) mh_xcalloc((size_t) (ncomps + 1), sizeof(struct comp *)))) { adios(EX_OSERR, NULL, "unable to allocate component buffer stack"); } diff --git a/uip/repl.c b/uip/repl.c index 33d4bf5..c0b290d 100644 --- a/uip/repl.c +++ b/uip/repl.c @@ -413,10 +413,10 @@ replout(FILE *inb, char *drft, struct msgs *mp, ncomps = fmt_compile(cp, &fmt) + 1; if (!(nxtbuf = compbuffers = (char **) - calloc((size_t) ncomps, sizeof(char *)))) + mh_xcalloc((size_t) ncomps, sizeof(char *)))) adios(EX_OSERR, NULL, "unable to allocate component buffers"); if (!(savecomp = used_buf = (struct comp **) - calloc((size_t) (ncomps+1), sizeof(struct comp *)))) + mh_xcalloc((size_t) (ncomps+1), sizeof(struct comp *)))) adios(EX_OSERR, NULL, "unable to allocate component buffer stack"); savecomp += ncomps + 1; *--savecomp = NULL; /* point at zero'd end minus 1 */