They never return NULL. That's their prime purpose.
* 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);
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)
*/
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);
*/
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))))
(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);
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;
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;
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);
}
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);
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);
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);
/*
* 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
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;
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;
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);
/*
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;
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);
}
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)
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;
}
}
/* 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 */
* 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)
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_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 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)
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;
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;
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;
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;
}
}
- 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))) {
}
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++) {
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);
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():
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;
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;
}
* 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)))
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++) {
(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) {
{
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;
* 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)))
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++) {
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_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 */
}
/* 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 */
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;
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 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
* 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)))
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;
/*
* 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))) {
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++) {
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;
{
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;
}
* 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)
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 {
* 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];
/*
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)) {