Add functions to allocate and free command contexts rather than doing it all on

the stack.
This commit is contained in:
Nicholas Marriott
2013-02-18 23:20:21 +00:00
parent 2a91025581
commit 293e331d69
12 changed files with 142 additions and 118 deletions

View File

@ -93,7 +93,7 @@ void
control_callback(struct client *c, int closed, unused void *data)
{
char *line, *cause;
struct cmd_ctx ctx;
struct cmd_ctx *ctx;
struct cmd_list *cmdlist;
if (closed)
@ -108,22 +108,24 @@ control_callback(struct client *c, int closed, unused void *data)
break;
}
ctx.msgdata = NULL;
ctx.cmdclient = NULL;
ctx.curclient = c;
ctx = cmd_get_ctx();
ctx->msgdata = NULL;
ctx->cmdclient = NULL;
ctx->curclient = c;
ctx.error = control_msg_error;
ctx.print = control_msg_print;
ctx.info = control_msg_info;
ctx->error = control_msg_error;
ctx->print = control_msg_print;
ctx->info = control_msg_info;
if (cmd_string_parse(line, &cmdlist, &cause) != 0) {
control_write(c, "%%error in line \"%s\": %s", line,
cause);
free(cause);
} else {
cmd_list_exec(cmdlist, &ctx);
cmd_list_exec(cmdlist, ctx);
cmd_list_free(cmdlist);
}
cmd_free_ctx(ctx);
free(line);
}