diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2013-02-18 23:20:21 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2013-02-18 23:20:21 +0000 |
commit | 293e331d69def60110bdc49b6453af905e0509b3 (patch) | |
tree | 3dbb4230607dc6bb0a40d3a1e9b71d0f56774c7a /key-bindings.c | |
parent | 2a91025581ddaa934ffa471f5b27a33d19e4ea2d (diff) | |
download | rtmux-293e331d69def60110bdc49b6453af905e0509b3.tar.gz rtmux-293e331d69def60110bdc49b6453af905e0509b3.tar.bz2 rtmux-293e331d69def60110bdc49b6453af905e0509b3.zip |
Add functions to allocate and free command contexts rather than doing it all on
the stack.
Diffstat (limited to 'key-bindings.c')
-rw-r--r-- | key-bindings.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/key-bindings.c b/key-bindings.c index cf5237d4..a25d3700 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -262,18 +262,18 @@ key_bindings_info(struct cmd_ctx *ctx, const char *fmt, ...) void key_bindings_dispatch(struct key_binding *bd, struct client *c) { - struct cmd_ctx ctx; + struct cmd_ctx *ctx; struct cmd *cmd; int readonly; - ctx.msgdata = NULL; - ctx.curclient = c; + ctx = cmd_get_ctx(); + ctx->msgdata = NULL; + ctx->cmdclient = NULL; + ctx->curclient = c; - ctx.error = key_bindings_error; - ctx.print = key_bindings_print; - ctx.info = key_bindings_info; - - ctx.cmdclient = NULL; + ctx->error = key_bindings_error; + ctx->print = key_bindings_print; + ctx->info = key_bindings_info; readonly = 1; TAILQ_FOREACH(cmd, &bd->cmdlist->list, qentry) { @@ -281,9 +281,10 @@ key_bindings_dispatch(struct key_binding *bd, struct client *c) readonly = 0; } if (!readonly && c->flags & CLIENT_READONLY) { - key_bindings_info(&ctx, "Client is read-only"); + key_bindings_info(ctx, "client is read-only"); return; } - cmd_list_exec(bd->cmdlist, &ctx); + cmd_list_exec(bd->cmdlist, ctx); + cmd_free_ctx(ctx); } |