]> git.neil.brown.name Git - edlib.git/commitdiff
keymap: switch to embedded-data pattern.
authorNeilBrown <neil@brown.name>
Fri, 8 Sep 2023 10:32:52 +0000 (20:32 +1000)
committerNeilBrown <neil@brown.name>
Fri, 8 Sep 2023 10:32:52 +0000 (20:32 +1000)
Signed-off-by: NeilBrown <neil@brown.name>
lib-keymap.c

index 39471644a10da937d9a738180726af29fdb81744..16e38f10376660a8015d01ef4ce2b833c3327490 100644 (file)
 
 #include <stdlib.h>
 #include <string.h>
+#define PANE_DATA_TYPE struct key_data
 #include "core.h"
 
 struct key_data {
        struct command  *globalcmd;
 };
+#include "core-pane.h"
 
 static struct pane *safe do_keymap_attach(struct pane *p safe);
 
@@ -27,11 +29,6 @@ DEF_CMD(keymap_handle)
                command_put(kd->globalcmd);
                return 1;
        }
-       if (strcmp(ci->key, "Free") == 0) {
-               free(kd);
-               ci->home->data = safe_cast NULL;
-               return 1;
-       }
        if (strcmp(ci->key, "Clone") == 0) {
                struct pane *p = do_keymap_attach(ci->focus);
                struct key_data *kd_old = ci->home->data;
@@ -67,10 +64,7 @@ DEF_CMD(keymap_handle)
 
 static struct pane *safe do_keymap_attach(struct pane *p safe)
 {
-       struct key_data *kd = malloc(sizeof(*kd));
-
-       kd->globalcmd = NULL;
-       return pane_register(p, 0, &keymap_handle, kd);
+       return pane_register(p, 0, &keymap_handle);
 }
 
 DEF_CMD(keymap_attach)