Replace free() with mh_free0()
[mmh] / uip / mhbuild.c
index 01acdb7..4ff06ef 100644 (file)
@@ -330,8 +330,7 @@ build_mime(char *infile)
        /*
        ** Allocate space for primary (outside) content
        */
-       if ((ct = (CT) mh_xcalloc(1, sizeof(*ct))) == NULL)
-               adios(EX_OSERR, NULL, "out of memory");
+       ct = mh_xcalloc(1, sizeof(*ct));
 
        /*
        ** Allocate structure for handling decoded content
@@ -435,8 +434,7 @@ build_mime(char *infile)
        ct->c_subtype = MULTI_MIXED;
        ct->c_file = getcpy(infile);
 
-       if ((m = (struct multipart *) mh_xcalloc(1, sizeof(*m))) == NULL)
-               adios(EX_OSERR, NULL, "out of memory");
+       m = mh_xcalloc(1, sizeof(*m));
        ct->c_ctparams = (void *) m;
        pp = &m->mp_parts;
 
@@ -455,8 +453,7 @@ build_mime(char *infile)
                if (!p)
                        continue;
 
-               if ((part = (struct part *) mh_xcalloc(1, sizeof(*part))) == NULL)
-                       adios(EX_OSERR, NULL, "out of memory");
+               part = mh_xcalloc(1, sizeof(*part));
                *pp = part;
                pp = &part->mp_next;
                part->mp_part = p;
@@ -536,8 +533,7 @@ init_decoded_content(CT ct)
 {
        CE ce;
 
-       if ((ce = (CE) mh_xcalloc(1, sizeof(*ce))) == NULL)
-               adios(EX_OSERR, NULL, "out of memory");
+       ce = mh_xcalloc(1, sizeof(*ce));
 
        ct->c_cefile     = ce;
        ct->c_ceopenfnx  = open7Bit;  /* since unencoded */
@@ -597,8 +593,7 @@ user_content(FILE *in, char *file, char *buf, CT *ctp)
        }
 
        /* allocate basic Content structure */
-       if ((ct = (CT) mh_xcalloc(1, sizeof(*ct))) == NULL)
-               adios(EX_OSERR, NULL, "out of memory");
+       ct = mh_xcalloc(1, sizeof(*ct));
        *ctp = ct;
 
        /* allocate basic structure for handling decoded content */
@@ -812,7 +807,7 @@ use_forw:
                                if (!*cp)
                                        adios(EX_DATAERR, NULL, "empty pipe command for #%s directive", ci->ci_type);
                                cp = getcpy(cp);
-                               free(ci->ci_magic);
+                               mh_free0(&(ci->ci_magic));
                                ci->ci_magic = cp;
                        } else {
                                /* record filename of decoded contents */
@@ -890,7 +885,7 @@ use_forw:
                                if (!m_convert(mp, cp))
                                        exit(EX_USAGE);
                }
-               free(folder);
+               mh_free0(&folder);
                free_ctinfo(ct);
 
                /*
@@ -906,9 +901,7 @@ use_forw:
                        ct->c_type = CT_MULTIPART;
                        ct->c_subtype = MULTI_DIGEST;
 
-                       if ((m = (struct multipart *)
-                                       mh_xcalloc(1, sizeof(*m))) == NULL)
-                               adios(EX_OSERR, NULL, "out of memory");
+                       m = mh_xcalloc(1, sizeof(*m));
                        ct->c_ctparams = (void *) m;
                        pp = &m->mp_parts;
 
@@ -918,9 +911,7 @@ use_forw:
                                        CT p;
                                        CE pe;
 
-                                       if ((p = (CT) mh_xcalloc(1, sizeof(*p)))
-                                                       == NULL)
-                                               adios(EX_OSERR, NULL, "out of memory");
+                                       p = mh_xcalloc(1, sizeof(*p));
                                        init_decoded_content(p);
                                        pe = p->c_cefile;
                                        if (get_ctinfo("message/rfc822", p, 0)
@@ -934,8 +925,7 @@ use_forw:
                                                        msgnum);
                                        pe->ce_file = getcpy(buffer);
 
-                                       if ((part = (struct part *) mh_xcalloc(1, sizeof(*part))) == NULL)
-                                               adios(EX_OSERR, NULL, "out of memory");
+                                       part = mh_xcalloc(1, sizeof(*part));
                                        *pp = part;
                                        pp = &part->mp_next;
                                        part->mp_part = p;
@@ -994,8 +984,7 @@ use_forw:
                ct->c_type = CT_MULTIPART;
                ct->c_subtype = vrsn;
 
-               if ((m = (struct multipart *) mh_xcalloc(1, sizeof(*m))) == NULL)
-                       adios(EX_OSERR, NULL, "out of memory");
+               m = mh_xcalloc(1, sizeof(*m));
                ct->c_ctparams = (void *) m;
 
                pp = &m->mp_parts;
@@ -1011,9 +1000,7 @@ use_forw:
                        if (!p)
                                continue;
 
-                       if ((part = (struct part *)
-                                       mh_xcalloc(1, sizeof(*part))) == NULL)
-                               adios(EX_OSERR, NULL, "out of memory");
+                       part = mh_xcalloc(1, sizeof(*part));
                        *pp = part;
                        pp = &part->mp_next;
                        part->mp_part = p;