aboutsummaryrefslogtreecommitdiff
path: root/vis-cmds.c
diff options
context:
space:
mode:
Diffstat (limited to 'vis-cmds.c')
-rw-r--r--vis-cmds.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/vis-cmds.c b/vis-cmds.c
index 969eec7..31c98f9 100644
--- a/vis-cmds.c
+++ b/vis-cmds.c
@@ -776,7 +776,6 @@ static bool cmd_langmap(Vis *vis, Win *win, Command *cmd, const char *argv[], Cu
}
static bool cmd_map(Vis *vis, Win *win, Command *cmd, const char *argv[], Cursor *cur, Filerange *range) {
- KeyBinding *binding = NULL;
bool mapped = false;
bool local = strstr(argv[0], "-") != NULL;
enum VisMode mode = str2vismode(argv[1]);
@@ -790,22 +789,18 @@ static bool cmd_map(Vis *vis, Win *win, Command *cmd, const char *argv[], Cursor
}
const char *lhs = argv[2];
- char *rhs = strdup(argv[3]);
- if (!rhs || !(binding = vis_binding_new(vis)))
+ KeyBinding *binding = vis_binding_new(vis);
+ if (!binding || !(binding->alias = strdup(argv[3])))
goto err;
- binding->alias = rhs;
-
if (local)
mapped = vis_window_mode_map(win, mode, cmd->flags == '!', lhs, binding);
else
mapped = vis_mode_map(vis, mode, cmd->flags == '!', lhs, binding);
err:
- if (!mapped) {
- free(rhs);
+ if (!mapped)
vis_binding_free(vis, binding);
- }
return mapped;
}