fix regressions
[apps/madmutt.git] / copy.c
diff --git a/copy.c b/copy.c
index 48dcabb..19b3d8c 100644 (file)
--- a/copy.c
+++ b/copy.c
@@ -11,6 +11,8 @@
 # include "config.h"
 #endif
 
+#include <lib-lib/mem.h>
+
 #include "mutt.h"
 #include "ascii.h"
 #include "handler.h"
@@ -126,7 +128,7 @@ mutt_copy_hdr (FILE* in, FILE* out, off_t off_start, off_t off_end,
 
   debug_print (1, ("WEED is %s\n", (flags & CH_WEED) ? "Set" : "Not"));
 
-  headers = mem_calloc (hdr_count, sizeof (char *));
+  headers = p_new(char *, hdr_count);
 
   /* Read all the headers into the array */
   while (ftello (in) < off_end) {
@@ -157,7 +159,7 @@ mutt_copy_hdr (FILE* in, FILE* out, off_t off_start, off_t off_end,
           mem_realloc (&headers[x], str_len (headers[x]) +
                         str_len (this_one) + sizeof (char));
           strcat (headers[x], this_one);        /* __STRCAT_CHECKED__ */
-          mem_free (&this_one);
+          p_delete(&this_one);
         }
 
         this_one = NULL;
@@ -250,7 +252,7 @@ mutt_copy_hdr (FILE* in, FILE* out, off_t off_start, off_t off_end,
       mem_realloc (&headers[x], str_len (headers[x]) +
                     str_len (this_one) + sizeof (char));
       strcat (headers[x], this_one);    /* __STRCAT_CHECKED__ */
-      mem_free (&this_one);
+      p_delete(&this_one);
     }
 
     this_one = NULL;
@@ -303,8 +305,8 @@ mutt_copy_hdr (FILE* in, FILE* out, off_t off_start, off_t off_end,
   /* Free in a separate loop to be sure that all headers are freed
    * in case of error. */
   for (x = 0; x < hdr_count; x++)
-    mem_free (&headers[x]);
-  mem_free (&headers);
+    p_delete(&headers[x]);
+  p_delete(&headers);
 
   if (error)
     return (-1);
@@ -390,7 +392,7 @@ mutt_copy_header (FILE * in, HEADER * h, FILE * out, int flags,
         /* Mutt stores references in reverse order, thus we create
          * a reordered refs list that we can put in the headers */
         for (; listp; listp = listp->next, refs = t) {
-          t = (LIST *) mem_malloc (sizeof (LIST));
+          t = p_new(LIST, 1);
           t->data = listp->data;
           t->next = refs;
         }
@@ -401,7 +403,7 @@ mutt_copy_header (FILE * in, HEADER * h, FILE * out, int flags,
 
         /* clearing refs from memory */
         for (t = refs; refs; refs = t->next, t = refs)
-          mem_free (&refs);
+          p_delete(&refs);
 
         if (fputc ('\n', out) == EOF)
           return (-1);
@@ -936,14 +938,12 @@ static int address_header_decode (char **h)
   mutt_addrlist_to_local (a);
   rfc2047_decode_adrlist (a);
 
-  *h = mem_calloc (1, l + 2);
-
-  strfcpy (*h, s, l + 1);
+  *h = p_dupstr(s, l + 1);
 
   format_address_header (h, a);
 
   rfc822_free_address (&a);
 
-  mem_free (&s);
+  p_delete(&s);
   return 1;
 }