Merge branch 'm_getfld2-meillo' into master
[mmh] / uip / mhl.c
index 8becba9..c089d8e 100644 (file)
--- a/uip/mhl.c
+++ b/uip/mhl.c
@@ -369,7 +369,7 @@ mhl_format(char *file, int width)
                                int n = 0;
 
                                /* split the fields */
-                               tmparray = brkstring(getcpy(++parptr), ",",
+                               tmparray = brkstring(mh_xstrdup(++parptr), ",",
                                                NULL);
                                /*
                                ** copy pointers to split fields
@@ -400,10 +400,10 @@ mhl_format(char *file, int width)
                        if (!c1->c_fstr && global.c_fstr) {
                                if ((c1->c_flags & DATEFMT) &&
                                                (global.c_flags & DATEFMT)) {
-                                       c1->c_fstr = getcpy(global.c_fstr);
+                                       c1->c_fstr = mh_xstrdup(global.c_fstr);
                                } else if ((c1->c_flags & ADDRFMT) &&
                                                (global.c_flags & ADDRFMT)) {
-                                       c1->c_fstr = getcpy(global.c_fstr);
+                                       c1->c_fstr = mh_xstrdup(global.c_fstr);
                                }
                        }
                        continue;
@@ -458,8 +458,8 @@ evalvar(struct mcomp *c1)
                        return 1;
                cp = concat("=", cp, NULL);
                fmtstr = new_fs(cp, NULL);
-               free(cp);
-               c1->c_fstr = getcpy(fmtstr);
+               mh_free0(&cp);
+               c1->c_fstr = mh_xstrdup(fmtstr);
                c1->c_flags |= FORMAT;
                return 0;
        }
@@ -468,7 +468,7 @@ evalvar(struct mcomp *c1)
                char *fmtstr;
 
                fmtstr = new_fs("=%(decode{text})", NULL);
-               c1->c_fstr = getcpy(fmtstr);
+               c1->c_fstr = mh_xstrdup(fmtstr);
                c1->c_flags |= FORMAT;
                return 0;
        }
@@ -530,7 +530,7 @@ ptos(char *name, char **s)
        }
        c = *parptr;
        *parptr = 0;
-       *s = getcpy(cp);
+       *s = mh_xstrdup(cp);
        if ((*parptr = c) == '"')
                parptr++;
        return 0;
@@ -586,8 +586,7 @@ process(char *fname, int ofilen, int ofilec)
        if (fp != stdin)
                fclose(fp);
        if (holder.c_text) {
-               free(holder.c_text);
-               holder.c_text = NULL;
+               mh_free0(&(holder.c_text));
        }
        free_queue(&msghd, &msgtl);
        for (c1 = fmthd; c1; c1 = c1->c_next)
@@ -661,8 +660,7 @@ mhlfile(FILE *fp, char *mname, int ofilen, int ofilec)
                                        holder.c_text = concat("(Message ",
                                                        mname, ")\n", NULL);
                                        putcomp(c1, &holder, ONECOMP);
-                                       free(holder.c_text);
-                                       holder.c_text = NULL;
+                                       mh_free0(&(holder.c_text));
                                        continue;
                                }
                                if (mh_strcasecmp(c1->c_name, "extras")==0) {
@@ -674,15 +672,14 @@ mhlfile(FILE *fp, char *mname, int ofilen, int ofilec)
                                        continue;
                                }
                                if (dobody && mh_strcasecmp(c1->c_name, "body")==0) {
-                                       holder.c_text = getcpy(f.value);
+                                       holder.c_text = mh_xstrdup(f.value);
                                        while (state == BODY2) {
                                                putcomp(c1, &holder, BODYCOMP);
                                                state = m_getfld2(state, &f, fp);
                                                free(holder.c_text);
-                                               holder.c_text = getcpy(f.value);
+                                               holder.c_text = mh_xstrdup(f.value);
                                        }
-                                       free(holder.c_text);
-                                       holder.c_text = NULL;
+                                       mh_free0(&(holder.c_text));
                                        continue;
                                }
                                for (c2 = msghd; c2; c2 = c2->c_next) {
@@ -776,21 +773,21 @@ mcomp_format(struct mcomp *c1, struct mcomp *c2)
 
                fmt_scan(c1->c_fmt, buffer, sizeof(buffer) - 1, dat);
                /* Don't need to append a newline, dctime() already did */
-               c2->c_text = getcpy(buffer);
+               c2->c_text = mh_xstrdup(buffer);
 
-               free(ap);
+               mh_free0(&ap);
                return;
        }
 
        (q = &pq)->pq_next = NULL;
        while ((cp = getname(ap))) {
-               p = (struct pqpair *) mh_xcalloc((size_t) 1, sizeof(*p));
+               p = mh_xcalloc(1, sizeof(*p));
 
                if ((mp = getm(cp, NULL, 0, AD_NAME, error)) == NULL) {
-                       p->pq_text = getcpy(cp);
-                       p->pq_error = getcpy(error);
+                       p->pq_text = mh_xstrdup(cp);
+                       p->pq_error = mh_xstrdup(error);
                } else {
-                       p->pq_text = getcpy(mp->m_text);
+                       p->pq_text = mh_xstrdup(mp->m_text);
                        mnfree(mp);
                }
                q = (q->pq_next = p);
@@ -813,11 +810,11 @@ mcomp_format(struct mcomp *c1, struct mcomp *c2)
                        c2->c_text = add(buffer, c2->c_text);
                }
 
-               free(p->pq_text);
+               mh_free0(&(p->pq_text));
                if (p->pq_error)
-                       free(p->pq_error);
+                       mh_free0(&(p->pq_error));
                q = p->pq_next;
-               free((char *) p);
+               mh_free0(&p);
        }
 
        c2->c_text = add("\n", c2->c_text);
@@ -831,15 +828,15 @@ add_queue(struct mcomp **head, struct mcomp **tail, char *name,
 {
        struct mcomp *c1;
 
-       c1 = (struct mcomp *) mh_xcalloc((size_t) 1, sizeof(*c1));
+       c1 = mh_xcalloc(1, sizeof(*c1));
 
        c1->c_flags = flags & ~INIT;
-       if ((c1->c_name = name ? getcpy(name) : NULL))
+       if ((c1->c_name = name ? mh_xstrdup(name) : NULL))
                c1->c_flags |= mcomp_flags(c1->c_name);
-       c1->c_text = text ? getcpy(text) : NULL;
+       c1->c_text = text ? mh_xstrdup(text) : NULL;
        if (flags & INIT) {
                if (global.c_ovtxt)
-                       c1->c_ovtxt = getcpy(global.c_ovtxt);
+                       c1->c_ovtxt = mh_xstrdup(global.c_ovtxt);
                c1->c_offset = global.c_offset;
                c1->c_ovoff = global. c_ovoff;
                c1->c_width = 0;
@@ -864,16 +861,16 @@ free_queue(struct mcomp **head, struct mcomp **tail)
        for (c1 = *head; c1; c1 = c2) {
                c2 = c1->c_next;
                if (c1->c_name)
-                       free(c1->c_name);
+                       mh_free0(&(c1->c_name));
                if (c1->c_text)
-                       free(c1->c_text);
+                       mh_free0(&(c1->c_text));
                if (c1->c_ovtxt)
-                       free(c1->c_ovtxt);
+                       mh_free0(&(c1->c_ovtxt));
                if (c1->c_fstr)
-                       free(c1->c_fstr);
+                       mh_free0(&(c1->c_fstr));
                if (c1->c_fmt)
-                       free((char *) c1->c_fmt);
-               free((char *) c1);
+                       mh_free0(&(c1->c_fmt));
+               mh_free0(&c1);
        }
 
        *head = *tail = NULL;