diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-12-27 23:22:01 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-12-27 23:29:04 +0100 |
| commit | f52050784e7e1426eafb5e69bc2fa37219415406 (patch) | |
| tree | 52ce0d5e3137ac77969ddb256a32e26910c43c98 /vis-lua.c | |
| parent | b7c6c43b64dd88a3f3cff692bf224654aef9b1e2 (diff) | |
| download | vis-f52050784e7e1426eafb5e69bc2fa37219415406.tar.gz vis-f52050784e7e1426eafb5e69bc2fa37219415406.tar.xz | |
vis: properly free dynamic key bindings
The handling of :unmap needs to be revisited at some point.
Diffstat (limited to 'vis-lua.c')
| -rw-r--r-- | vis-lua.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -669,8 +669,11 @@ static int keymap(lua_State *L, Vis *vis, Win *win) { if (!key || !lua_isfunction(L, 4)) goto err; const char *help = luaL_optstring(L, 5, NULL); - if (!(binding = calloc(1, sizeof *binding)) || !(action = calloc(1, sizeof *action))) + if (!(binding = vis_binding_new(vis))) goto err; + if (!(action = calloc(1, sizeof *action))) + goto err; + binding->action = action; /* store reference to function in the registry */ lua_pushvalue(L, 4); @@ -687,8 +690,6 @@ static int keymap(lua_State *L, Vis *vis, Win *win) { }, }; - binding->action = action; - if (win) { if (!vis_window_mode_map(win, mode, true, key, binding)) goto err; @@ -700,8 +701,7 @@ static int keymap(lua_State *L, Vis *vis, Win *win) { lua_pushboolean(L, true); return 1; err: - free(binding); - free(action); + vis_binding_free(vis, binding); lua_pushboolean(L, false); return 1; } |
