]> diplodocus.org Git - nmh/blobdiff - uip/mhlsbr.c
Tweak mh_xmalloc(); print size in error, allocate zero bytes.
[nmh] / uip / mhlsbr.c
index 3bc080856d02f663c51f0a765ed35afdce34c452..6cca758001249f31592c1e08d62bca0d66d8783a 100644 (file)
@@ -908,6 +908,7 @@ process (char *folder, char *fname, int ofilen, int ofilec)
            if (ontty != PITTY)
                SIGNAL (SIGINT, intrser);
            mhlfile (fp, cp, ofilen, ofilec);  /* FALL THROUGH! */
+            free (cp);
 
            for (ap = arglist_head; ap; ap = ap->a_next) {
                fmt_free(ap->a_fmt, 0);
@@ -922,7 +923,6 @@ process (char *folder, char *fname, int ofilen, int ofilec)
                SIGNAL (SIGINT, SIG_IGN);
            if (mhl_action == NULL && fp != stdin && fp != NULL)
                fclose (fp);
-               free (cp);
            if (holder.c_text) {
                free (holder.c_text);
                holder.c_text = NULL;
@@ -1188,18 +1188,15 @@ mcomp_format (struct mcomp *c1, struct mcomp *c2)
 
     (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) {
@@ -1244,22 +1241,19 @@ add_queue (struct mcomp **head, struct mcomp **tail, char *name, char *text, int
 {
     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;