use safer p_clear when possible.
[apps/madmutt.git] / keymap.c
index 73234e1..abfc8c3 100644 (file)
--- a/keymap.c
+++ b/keymap.c
 #endif
 
 #include <lib-lib/mem.h>
+#include <lib-lib/ascii.h>
+#include <lib-lib/str.h>
+#include <lib-lib/macros.h>
 
 #include "mutt.h"
 #include "buffer.h"
-#include "ascii.h"
 #include "mutt_menu.h"
 #include "mutt_curses.h"
 #include "keymap.h"
 #include "mapping.h"
 #include "mutt_crypt.h"
 
-#include "lib/intl.h"
-#include "lib/str.h"
 
 #include <stdlib.h>
 #include <string.h>
@@ -194,8 +194,8 @@ void km_bind (const char *s, int menu, int op, char *macro, char *descr)
 
   map = allocKeys (len, buf);
   map->op = op;
-  map->macro = str_dup (macro);
-  map->descr = str_dup (descr);
+  map->macro = m_strdup(macro);
+  map->descr = m_strdup(descr);
 
   tmp = Keymaps[menu];
 
@@ -252,7 +252,7 @@ static int get_op (struct binding_t *bindings, const char *start, size_t len)
 
   for (i = 0; bindings[i].name; i++) {
     if (!ascii_strncasecmp (start, bindings[i].name, len) &&
-        str_len (bindings[i].name) == len)
+        m_strlen(bindings[i].name) == len)
       return bindings[i].op;
   }
 
@@ -274,7 +274,7 @@ static const char *get_func (struct binding_t *bindings, int op)
 
 static void push_string (char *s)
 {
-  char *pp, *p = s + str_len (s) - 1;
+  char *pp, *p = s + m_strlen(s) - 1;
   size_t l;
   int i, op = OP_NULL;
 
@@ -493,7 +493,7 @@ int km_expand_key (char *s, size_t len, struct keymap_t *map)
 
   FOREVER {
     strfcpy (s, km_keyname (map->keys[p]), len);
-    len -= (l = str_len (s));
+    len -= (l = m_strlen(s));
 
     if (++p >= map->len || !len)
       return (1);
@@ -516,7 +516,7 @@ struct keymap_t *km_find_func (int menu, int func)
 
 void km_init (void)
 {
-  memset (Keymaps, 0, sizeof (struct keymap_t *) * MENU_MAX);
+  p_clear(Keymaps, MENU_MAX);
 
   create_bindings (OpAttach, MENU_ATTACH);
   create_bindings (OpBrowser, MENU_FOLDER);
@@ -677,7 +677,7 @@ static char *parse_keymap (int *menu, BUFFER * s, int maxmenus, int *nummenus,
   int i = 0;
   char *p, *q;
 
-  memset (&buf, 0, sizeof (buf));
+  p_clear(&buf, 1);
 
   /* menu name */
   mutt_extract_token (&buf, s, 0);
@@ -837,7 +837,7 @@ int mutt_parse_macro (BUFFER * buf, BUFFER * s, unsigned long data,
   }
   else {
     if (MoreArgs (s)) {
-      seq = str_dup (buf->data);
+      seq = m_strdup(buf->data);
       mutt_extract_token (buf, s, M_TOKEN_CONDENSE);
 
       if (MoreArgs (s)) {
@@ -885,9 +885,9 @@ int mutt_parse_exec (BUFFER * buf, BUFFER * s, unsigned long data,
         && CurrentMenu != MENU_PAGER)
       bindings = OpGeneric;
 
-    ops[nops] = get_op (bindings, function, str_len (function));
+    ops[nops] = get_op (bindings, function, m_strlen(function));
     if (ops[nops] == OP_NULL && CurrentMenu != MENU_PAGER)
-      ops[nops] = get_op (OpGeneric, function, str_len (function));
+      ops[nops] = get_op (OpGeneric, function, m_strlen(function));
 
     if (ops[nops] == OP_NULL) {
       mutt_flushinp ();