]> diplodocus.org Git - nmh/blobdiff - uip/mhparse.c
Replace getcpy() with mh_xstrdup() where the string isn't NULL.
[nmh] / uip / mhparse.c
index 7e539c3a8eabc276a0cd1720b2c6dcec4cac8172..7b1352aa4a17c08ec239b65bc1903a60d9a4657e 100644 (file)
@@ -294,7 +294,7 @@ get_content (FILE *in, char *file, int toplevel)
     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;
@@ -581,7 +581,7 @@ add_header (CT ct, char *name, char *value)
     HF hp;
 
     /* allocate header field structure */
-    hp = mh_xmalloc (sizeof(*hp));
+    NEW(hp);
 
     /* link data into header structure */
     hp->name = name;
@@ -1027,7 +1027,7 @@ InitText (CT ct)
     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 */
@@ -1131,7 +1131,7 @@ InitMultiPart (CT ct)
     }
 
     /* 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 */
@@ -1175,7 +1175,7 @@ InitMultiPart (CT ct)
            if (strcmp (bufp + 2, m->mp_start))
                continue;
 next_part:
-           part = mh_xcalloc(1, sizeof *part);
+           NEW0(part);
            *next = part;
            next = &part->mp_next;
 
@@ -1414,7 +1414,7 @@ InitMessage (CT ct)
                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" */
@@ -1462,7 +1462,7 @@ invalid_param:
                CT p;
                FILE *fp;
 
-               e = mh_xcalloc(1, sizeof *e);
+               NEW0(e);
                ct->c_ctparams = (void *) e;
 
                if (!ct->c_fp
@@ -3537,8 +3537,7 @@ bad_quote:
            }
 
            if (pp == NULL) {
-               pp = mh_xmalloc(sizeof(*pp));
-               memset(pp, 0, sizeof(*pp));
+               NEW0(pp);
                pp->name = nameptr;
                pp->next = phead;
                phead = pp;
@@ -3548,8 +3547,7 @@ bad_quote:
             * Insert this into the section linked list
             */
 
-           sp = mh_xmalloc(sizeof(*sp));
-           memset(sp, 0, sizeof(*sp));
+           NEW0(sp);
            sp->value = valptr;
            sp->index = index;
            sp->len = len;
@@ -3665,7 +3663,7 @@ content_charset (CT ct) {
 
     ret_charset = get_param(ct->c_ctinfo.ci_first_pm, "charset", '?', 0);
 
-    return ret_charset ? ret_charset : getcpy ("US-ASCII");
+    return ret_charset ? ret_charset : mh_xstrdup("US-ASCII");
 }
 
 
@@ -4082,10 +4080,9 @@ normal_param(PM pm, char *output, size_t len, size_t valuelen,
 PM
 add_param(PM *first, PM *last, char *name, char *value, int nocopy)
 {
-    PM pm = mh_xmalloc(sizeof(*pm));
-
-    memset(pm, 0, sizeof(*pm));
+    PM pm;
 
+    NEW0(pm);
     pm->pm_name = nocopy ? name : getcpy(name);
     pm->pm_value = nocopy ? value : getcpy(value);