summaryrefslogtreecommitdiff
path: root/keymaps.c
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2011-11-23 19:24:14 -0500
committerChet Ramey <chet.ramey@case.edu>2011-11-23 19:24:14 -0500
commit86cfd01f1d547422a1fb0365719491a355847dc0 (patch)
tree131fc20f78755a99c8d5db62c39609d0c4cafe0f /keymaps.c
parentff2d9ff725d1d8591f3534ed2a992b550b56a832 (diff)
downloadreadline-86cfd01f1d547422a1fb0365719491a355847dc0.tar.gz
Readline-6.1 import
Diffstat (limited to 'keymaps.c')
-rw-r--r--keymaps.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/keymaps.c b/keymaps.c
index a033d5e..9379dec 100644
--- a/keymaps.c
+++ b/keymaps.c
@@ -57,8 +57,9 @@ Keymap
rl_make_bare_keymap ()
{
register int i;
- Keymap keymap = (Keymap)xmalloc (KEYMAP_SIZE * sizeof (KEYMAP_ENTRY));
+ Keymap keymap;
+ keymap = (Keymap)xmalloc (KEYMAP_SIZE * sizeof (KEYMAP_ENTRY));
for (i = 0; i < KEYMAP_SIZE; i++)
{
keymap[i].type = ISFUNC;
@@ -76,7 +77,8 @@ rl_make_bare_keymap ()
return (keymap);
}
-/* Return a new keymap which is a copy of MAP. */
+/* Return a new keymap which is a copy of MAP. Just copies pointers, does
+ not copy text of macros or descend into child keymaps. */
Keymap
rl_copy_keymap (map)
Keymap map;
@@ -128,7 +130,7 @@ rl_discard_keymap (map)
{
int i;
- if (!map)
+ if (map == 0)
return;
for (i = 0; i < KEYMAP_SIZE; i++)
@@ -140,6 +142,7 @@ rl_discard_keymap (map)
case ISKMAP:
rl_discard_keymap ((Keymap)map[i].function);
+ free ((char *)map[i].function);
break;
case ISMACR:
@@ -148,3 +151,12 @@ rl_discard_keymap (map)
}
}
}
+
+/* Convenience function that discards, then frees, MAP. */
+void
+rl_free_keymap (map)
+ Keymap map;
+{
+ rl_discard_keymap (map);
+ free ((char *)map);
+}