move buffer.[hc] into lib-lib/
[apps/madmutt.git] / recvattach.c
index 30bcb49..99a8917 100644 (file)
 # include "config.h"
 #endif
 
+#include <lib-lib/mem.h>
+#include <lib-lib/str.h>
+#include <lib-lib/macros.h>
+#include <lib-lib/ascii.h>
+
 #include "mutt.h"
-#include "ascii.h"
 #include "enter.h"
 #include "handler.h"
 #include "recvattach.h"
@@ -27,9 +31,6 @@
 #include "copy.h"
 #include "mutt_crypt.h"
 
-#include "lib/mem.h"
-#include "lib/intl.h"
-#include "lib/str.h"
 
 #include <ctype.h>
 #include <stdlib.h>
@@ -57,12 +58,12 @@ static struct mapping_t AttachHelp[] = {
   {N_("Pipe"), OP_PIPE},
   {N_("Print"), OP_PRINT},
   {N_("Help"), OP_HELP},
-  {NULL}
+  {NULL, OP_NULL}
 };
 
 static int mutt_extract_path (char *filename, char *path)
 {
-  char *tmp = mem_malloc (sizeof (char) * _POSIX_PATH_MAX);
+  char *tmp = p_new(char, _POSIX_PATH_MAX);
   char *help_ptr;
 
   help_ptr = tmp;
@@ -76,7 +77,7 @@ static int mutt_extract_path (char *filename, char *path)
     }
     *help_ptr++ = *filename++;
   }
-  mem_free (&tmp);
+  p_delete(&tmp);
   return 0;
 }
 
@@ -105,7 +106,7 @@ void mutt_update_tree (ATTACHPTR ** idx, short idxlen)
         str_replace (&idx[x]->tree, buf);
     }
     else
-      idx[x]->tree = str_dup (buf);
+      idx[x]->tree = m_strdup(buf);
 
     if (2 * (idx[x]->level + 2) < sizeof (buf) && idx[x]->level) {
       s = buf + 2 * (idx[x]->level - 1);
@@ -126,7 +127,7 @@ ATTACHPTR **mutt_gen_attach_list (BODY * m,
 
   for (; m; m = m->next) {
     if (*idxlen == *idxmax) {
-      mem_realloc (&idx, sizeof (ATTACHPTR *) * ((*idxmax) += 5));
+      p_realloc(&idx, (*idxmax) += 5);
       for (i = *idxlen; i < *idxmax; i++)
         idx[i] = NULL;
     }
@@ -144,7 +145,7 @@ ATTACHPTR **mutt_gen_attach_list (BODY * m,
     }
     else {
       if (!idx[*idxlen])
-        idx[*idxlen] = (ATTACHPTR *) mem_calloc (1, sizeof (ATTACHPTR));
+        idx[*idxlen] = p_new(ATTACHPTR, 1);
 
       new = idx[(*idxlen)++];
       new->content = m;
@@ -550,7 +551,7 @@ void mutt_save_attachment_list (FILE * fp, int tag, BODY * top, HEADER * hdr,
       break;
   }
 
-  mem_free (&directory);
+  p_delete(&directory);
 
   if (tag && menu) {
     menu->oldcurrent = menu->current;
@@ -646,7 +647,7 @@ void mutt_pipe_attachment_list (FILE * fp, int tag, BODY * top, int filter)
     filter = 0;                 /* sanity check: we can't filter in the recv case yet */
 
   buf[0] = 0;
-  memset (&state, 0, sizeof (STATE));
+  p_clear(&state, 1);
 
   if (mutt_get_field ((filter ? _("Filter through: ") : _("Pipe to: ")),
                       buf, sizeof (buf), M_CMD) != 0 || !buf[0])
@@ -750,7 +751,7 @@ void mutt_print_attachment_list (FILE * fp, int tag, BODY * top)
     if (!can_print (top, tag))
       return;
     mutt_endwin (NULL);
-    memset (&state, 0, sizeof (STATE));
+    p_clear(&state, 1);
     thepid = mutt_create_filter (NONULL (PrintCmd), &state.fpout, NULL, NULL);
     print_attachment_list (fp, tag, top, &state);
     fclose (state.fpout);
@@ -1241,12 +1242,12 @@ void mutt_view_attachments (HEADER * hdr)
           hdr->attach_del = 1;
         if (idx[idxmax]->content)
           idx[idxmax]->content->aptr = NULL;
-        mem_free (&idx[idxmax]->tree);
-        mem_free (&idx[idxmax]);
+        p_delete(&idx[idxmax]->tree);
+        p_delete(&idx[idxmax]);
       }
       if (hdr->attach_del)
         hdr->changed = 1;
-      mem_free (&idx);
+      p_delete(&idx);
       idxmax = 0;
 
       if (WithCrypto && need_secured && secured) {