mem_calloc -> p_new
[apps/madmutt.git] / recvattach.c
index f770915..e71d85b 100644 (file)
@@ -12,6 +12,8 @@
 # include "config.h"
 #endif
 
+#include <lib-lib/mem.h>
+
 #include "mutt.h"
 #include "ascii.h"
 #include "enter.h"
@@ -49,18 +51,20 @@ static char LastSaveFolder[_POSIX_PATH_MAX] = "";
     break; \
 }
 
+#define SW              (option(OPTMBOXPANE)?SidebarWidth:0)
+
 static struct mapping_t AttachHelp[] = {
   {N_("Exit"), OP_EXIT},
   {N_("Save"), OP_SAVE},
   {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;
@@ -74,7 +78,7 @@ static int mutt_extract_path (char *filename, char *path)
     }
     *help_ptr++ = *filename++;
   }
-  mem_free (&tmp);
+  p_delete(&tmp);
   return 0;
 }
 
@@ -142,7 +146,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;
@@ -367,7 +371,8 @@ const char *mutt_attach_fmt (char *dest,
 
 static void attach_entry (char *b, size_t blen, MUTTMENU * menu, int num)
 {
-  mutt_FormatString (b, blen, NONULL (AttachFormat), mutt_attach_fmt,
+  int w=(COLS-SW)>blen?blen:(COLS-SW);
+  mutt_FormatString (b, w, NONULL (AttachFormat), mutt_attach_fmt,
                      (unsigned long) (((ATTACHPTR **) menu->data)[num]),
                      M_FORMAT_ARROWCURSOR);
 }
@@ -547,7 +552,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;
@@ -1238,12 +1243,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) {