/* Call free(3), if ptr isn't NULL. */
void mh_xfree(void *ptr);
+/* Set p to point to newly allocated, zeroed, memory. */
+#define NEW0(p) ((p) = mh_xcalloc(1, sizeof *(p)))
+
char *pwd(void);
char *add(const char *, char *);
char *addlist(char *, const char *);
dftype = LOCALHOST;
}
- mp = mh_xcalloc(1, sizeof *mp);
+ NEW0(mp);
mp->m_next = NULL;
mp->m_text = getcpy (str);
if (pers)
! strcasecmp ("VTIMEZONE", node->value)) {
in_vtimezone = 1;
- timezone = mh_xcalloc (1, sizeof (struct tzdesc));
+ NEW0(timezone);
if (timezones) {
tzdesc_t t;
/* Add new component to the hash table */
#define NEWCOMP(cm,name) do { \
- cm = ((struct comp *) mh_xcalloc (1, sizeof (struct comp)));\
+ NEW0(cm);\
cm->c_name = getcpy(name);\
cm->c_refcount++;\
ncomp++;\
if (cm->c_tws) {
memset (cm->c_tws, 0, sizeof *cm->c_tws);
} else {
- cm->c_tws = mh_xcalloc (1, sizeof *cm->c_tws);
+ NEW0(cm->c_tws);
}
fp->f_type = preprocess;
PUTCOMP(sp);
contentline *
add_contentline (contentline *node, const char *name) {
- contentline *new_node = mh_xcalloc (1, sizeof (contentline));
+ contentline *new_node;
+ NEW0(new_node);
new_node->name = strdup (name);
new_node->next = node->next;
node->next = new_node;
static void
new_input_line (contentline **cline) {
- contentline *new_node = mh_xcalloc (1, sizeof (contentline));
+ contentline *new_node;
+ NEW0(new_node);
if (*cline) {
/* Append the new node to the end of the list. */
(*cline)->last->next = new_node;
static void
new_vevent (vevent *event) {
- vevent *new_node = mh_xcalloc (1, sizeof (vevent)), *node;
+ vevent *new_node, *node;
+
+ NEW0(new_node);
/* Append the new node to the end of the list. */
for (node = event; node->next; node = node->next) { continue; }
void
add_param_name (contentline *cline, char *name) {
- param_list *new_node = mh_xcalloc (1, sizeof (param_list));
+ param_list *new_node;
param_list *p;
+ NEW0(new_node);
new_node->param_name = name;
if (cline->params) {
*/
void
add_param_value (contentline *cline, char *value) {
- value_list *new_node = mh_xcalloc (1, sizeof (value_list));
+ value_list *new_node;
param_list *p;
value_list *v;
+ NEW0(new_node);
new_node->value = value;
if (cline->params) {
(q = &pq)->pq_next = NULL;
while ((cp = getname (arg))) {
- p = mh_xcalloc(1, sizeof *p);
+ NEW0(p);
if ((mp = getm (cp, NULL, 0, error, sizeof(error))) == NULL) {
p->pq_text = getcpy (cp);
p->pq_error = getcpy (error);
for (i = 0; i < addrs->size; i++) {
(q = &pq)->pq_next = NULL;
while ((cp = getname(addrs->msgs[i]))) {
- p = mh_xcalloc(1, sizeof *p);
+ NEW0(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
*/
- ct = mh_xcalloc(1, sizeof *ct);
+ NEW0(ct);
/*
* Allocate structure for handling decoded content
convert->filename = getcpy (filename);
}
} else {
- convert = mh_xcalloc (sizeof *convert, 1);
+ NEW0(convert);
convert->filename = getcpy (filename);
convert->type = getcpy (type);
convert->argstring = getcpy (argstring);
}
} else {
- convert = mh_xcalloc (sizeof *convert, 1);
+ NEW0(convert);
convert->type = getcpy (type);
convert->argstring = getcpy (argstring);
ct->c_type = CT_MULTIPART;
ct->c_subtype = MULTI_MIXED;
- m = mh_xcalloc(1, sizeof *m);
+ NEW0(m);
ct->c_ctparams = (void *) m;
pp = &m->mp_parts;
if (!p)
continue;
- part = mh_xcalloc(1, sizeof *part);
+ NEW0(part);
*pp = part;
pp = &part->mp_next;
part->mp_part = p;
adios("reading", "Unable to open %s for", at_entry->filename);
}
- p = mh_xcalloc(1, sizeof *p);
+ NEW0(p);
init_decoded_content(p, infile);
/*
setup_attach_content(p, at_entry->filename);
- part = mh_xcalloc(1, sizeof *part);
+ NEW0(part);
*pp = part;
pp = &part->mp_next;
part->mp_part = p;
struct part *part;
struct text *t;
- p = mh_xcalloc(1, sizeof *p);
+ NEW0(p);
init_decoded_content(p, infile);
if (get_ctinfo ("text/plain", p, 0) == NOTOK)
p->c_begin = ftell(in);
p->c_end = ftell(in);
- t = mh_xcalloc(1, sizeof *t);
+ NEW0(t);
t->tx_charset = CHARSET_SPECIFIED;
p->c_ctparams = t;
- part = mh_xcalloc(1, sizeof *part);
+ NEW0(part);
*pp = part;
part->mp_part = p;
}
}
/* allocate basic Content structure */
- ct = mh_xcalloc(1, sizeof *ct);
+ NEW0(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.
*/
- ct = mh_xcalloc(1, sizeof *ct);
+ NEW0(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;
- e = mh_xcalloc(1, sizeof *e);
+ NEW0(e);
ct->c_ctparams = (void *) e;
e->eb_parent = ct;
ct->c_type = CT_MULTIPART;
ct->c_subtype = MULTI_DIGEST;
- m = mh_xcalloc(1, sizeof *m);
+ NEW0(m);
ct->c_ctparams = (void *) m;
pp = &m->mp_parts;
CT p;
CE pe;
- p = mh_xcalloc(1, sizeof *p);
+ NEW0(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;
- part = mh_xcalloc(1, sizeof *part);
+ NEW0(part);
*pp = part;
pp = &part->mp_next;
part->mp_part = p;
ct->c_type = CT_MULTIPART;
ct->c_subtype = vrsn;
- m = mh_xcalloc(1, sizeof *m);
+ NEW0(m);
ct->c_ctparams = (void *) m;
pp = &m->mp_parts;
if (!p)
continue;
- part = mh_xcalloc(1, sizeof *part);
+ NEW0(part);
*pp = part;
pp = &part->mp_next;
part->mp_part = p;
struct text *t;
if (ct->c_ctparams == NULL) {
- t = ct->c_ctparams = mh_xcalloc(1, sizeof *t);
+ NEW0(t);
+ ct->c_ctparams = t;
t->tx_charset = CHARSET_UNSPECIFIED;
} else {
t = (struct text *) ct->c_ctparams;
free (convert_command);
/* Fill out the the new ct, reply_ct. */
- reply_ct = (CT) mh_xcalloc (1, sizeof *reply_ct);
+ NEW0(reply_ct);
init_decoded_content (reply_ct, infile);
if (extract_headers (reply_ct, reply_file, &reply_fp) == NOTOK) {
reply_ct->c_cefile.ce_unlink = 1;
/* Attach the new part to the parent multipart/mixed, "m". */
- part = (struct part *) mh_xcalloc (1, sizeof *part);
+ NEW0(part);
part->mp_part = reply_ct;
if (m->mp_parts) {
struct part *p;
divide_part (CT ct) {
CT new_part;
- new_part = mh_xcalloc(1, sizeof *new_part);
+ NEW0(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;
- ct = mh_xcalloc(1, sizeof *ct);
+ NEW0(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;
- m = mh_xcalloc(1, sizeof *m);
+ NEW0(m);
m->mp_start = concat (boundary, "\n", NULL);
m->mp_stop = concat (boundary, "--\n", NULL);
m->mp_parts = p;
return 1;
}
- args = (struct arglist *) mh_xcalloc ((size_t) 1, sizeof(struct arglist));
+ NEW0(args);
if (arglist_tail)
arglist_tail->a_next = args;
(q = &pq)->pq_next = NULL;
while ((cp = getname (ap))) {
- p = mh_xcalloc(1, sizeof *p);
+ NEW0(p);
if ((mp = getm (cp, NULL, 0, error, sizeof(error))) == NULL) {
p->pq_text = getcpy (cp);
p->pq_error = getcpy (error);
{
struct mcomp *c1;
- c1 = mh_xcalloc(1, sizeof *c1);
+ NEW0(c1);
c1->c_flags = flags & ~INIT;
if ((c1->c_name = name ? getcpy (name) : NULL))
c1->c_flags |= mcomp_flags (c1->c_name);
m_getfld_state_t gstate = 0;
/* allocate the content structure */
- ct = mh_xcalloc(1, sizeof *ct);
+ NEW0(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 */
- t = mh_xcalloc(1, sizeof *t);
+ NEW0(t);
ct->c_ctparams = (void *) t;
/* scan for charset parameter */
}
/* allocate primary structure for multipart info */
- m = mh_xcalloc(1, sizeof *m);
+ NEW0(m);
ct->c_ctparams = (void *) m;
/* check if boundary parameter contains only whitespace characters */
if (strcmp (bufp + 2, m->mp_start))
continue;
next_part:
- part = mh_xcalloc(1, sizeof *part);
+ NEW0(part);
*next = part;
next = &part->mp_next;
PM pm;
struct partial *p;
- p = mh_xcalloc(1, sizeof *p);
+ NEW0(p);
ct->c_ctparams = (void *) p;
/* scan for parameters "id", "number", and "total" */
CT p;
FILE *fp;
- e = mh_xcalloc(1, sizeof *e);
+ NEW0(e);
ct->c_ctparams = (void *) e;
if (!ct->c_fp
{
register struct nexus *p;
- p = mh_xcalloc(1, sizeof *p);
+ NEW0(p);
p->n_action = action;
return p;
}
if (datecomp) {
if (! datecomp->c_text) {
if (datecomp->c_tws == NULL)
- datecomp->c_tws = mh_xcalloc(1, sizeof *datecomp->c_tws);
+ NEW0(datecomp->c_tws);
*datecomp->c_tws = *dlocaltime ((time_t *) &st.st_mtime);
datecomp->c_flags |= CF_DATEFAB|CF_TRUE;
} else {