fix regressions
[apps/madmutt.git] / enter.c
diff --git a/enter.c b/enter.c
index 2f7a0f3..1b97bd4 100644 (file)
--- a/enter.c
+++ b/enter.c
 # include "config.h"
 #endif
 
+#include <lib-lib/mem.h>
+
 #include "mutt.h"
+#include "enter.h"
 #include "mutt_menu.h"
 #include "mutt_curses.h"
 #include "keymap.h"
@@ -144,11 +147,11 @@ size_t my_mbstowcs (wchar_t ** pwbuf, size_t * pwbuflen, size_t i, char *buf)
  * Replace part of the wchar_t buffer, from FROM to CURPOS, by BUF.
  */
 
-static void replace_part (ENTER_STATE * state, size_t from, char *buf)
+static void replace_part (ENTER_STATE *state, size_t from, const char *buf)
 {
   /* Save the suffix */
   size_t savelen = state->lastchar - state->curpos;
-  wchar_t *savebuf = mem_calloc (savelen, sizeof (wchar_t));
+  wchar_t *savebuf = p_new(wchar_t, savelen);
 
   memcpy (savebuf, state->wbuf + state->curpos, savelen * sizeof (wchar_t));
 
@@ -165,7 +168,7 @@ static void replace_part (ENTER_STATE * state, size_t from, char *buf)
   memcpy (state->wbuf + state->curpos, savebuf, savelen * sizeof (wchar_t));
   state->lastchar = state->curpos + savelen;
 
-  mem_free (&savebuf);
+  p_delete(&savebuf);
 }
 
 /*
@@ -274,13 +277,13 @@ int _mutt_enter_string (char *buf, size_t buflen, int y, int x,
       switch (ch) {
       case OP_EDITOR_HISTORY_UP:
         state->curpos = state->lastchar;
-        replace_part (state, 0, mutt_history_prev (hclass));
+        replace_part(state, 0, mutt_history_prev(hclass));
         redraw = M_REDRAW_INIT;
         break;
 
       case OP_EDITOR_HISTORY_DOWN:
         state->curpos = state->lastchar;
-        replace_part (state, 0, mutt_history_next (hclass));
+        replace_part(state, 0, mutt_history_next(hclass));
         redraw = M_REDRAW_INIT;
         break;
 
@@ -635,7 +638,7 @@ int _mutt_enter_string (char *buf, size_t buflen, int y, int x,
           char **tfiles;
 
           *numfiles = 1;
-          tfiles = mem_calloc (*numfiles, sizeof (char *));
+          tfiles = p_new(char *, *numfiles);
           mutt_expand_path (buf, buflen);
           tfiles[0] = str_dup (buf);
           *files = tfiles;
@@ -662,7 +665,7 @@ int _mutt_enter_string (char *buf, size_t buflen, int y, int x,
 
 bye:
 
-  mem_free (&tempbuf);
+  p_delete(&tempbuf);
   return rv;
 }
 
@@ -671,8 +674,8 @@ void mutt_free_enter_state (ENTER_STATE ** esp)
   if (!esp)
     return;
 
-  mem_free (&(*esp)->wbuf);
-  mem_free (esp);
+  p_delete(&(*esp)->wbuf);
+  p_delete(esp);
 }
 
 /*