summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2013-03-22 15:50:13 +0000
committernicm <nicm@openbsd.org>2013-03-22 15:50:13 +0000
commit426dbf97715fb2148e63ba266a0a7839e83e8772 (patch)
treee0efdd8360a2f3df0837b77a28ada17edec22e9e
parentAdd functions to allocate and free command contexts rather than doing it (diff)
downloadwireguard-openbsd-426dbf97715fb2148e63ba266a0a7839e83e8772.tar.xz
wireguard-openbsd-426dbf97715fb2148e63ba266a0a7839e83e8772.zip
load_cfg can actually use the same context now they are reference counted.
-rw-r--r--usr.bin/tmux/cfg.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/usr.bin/tmux/cfg.c b/usr.bin/tmux/cfg.c
index 80f1b06fb31..61fbe611725 100644
--- a/usr.bin/tmux/cfg.c
+++ b/usr.bin/tmux/cfg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cfg.c,v 1.25 2013/03/22 15:49:55 nicm Exp $ */
+/* $OpenBSD: cfg.c,v 1.26 2013/03/22 15:50:13 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -73,14 +73,13 @@ cfg_add_cause(struct causelist *causes, const char *fmt, ...)
* causes. Note that causes must be initialised by the caller!
*/
enum cmd_retval
-load_cfg(const char *path, struct cmd_ctx *ctxin, struct causelist *causes)
+load_cfg(const char *path, struct cmd_ctx *ctx, struct causelist *causes)
{
FILE *f;
u_int n;
char *buf, *copy, *line, *cause;
size_t len, oldlen;
struct cmd_list *cmdlist;
- struct cmd_ctx *ctx;
enum cmd_retval retval;
if ((f = fopen(path, "rb")) == NULL) {
@@ -90,21 +89,15 @@ load_cfg(const char *path, struct cmd_ctx *ctxin, struct causelist *causes)
cfg_references++;
- ctx = cmd_get_ctx();
- if (ctxin == NULL) {
- ctx->msgdata = NULL;
- ctx->curclient = NULL;
- ctx->cmdclient = NULL;
- } else {
- ctx->msgdata = ctxin->msgdata;
- ctx->curclient = ctxin->curclient;
- ctx->cmdclient = ctxin->cmdclient;
+ if (ctx != NULL)
+ cmd_ref_ctx(ctx);
+ else {
+ ctx = cmd_get_ctx();
+ ctx->error = cfg_error;
+ ctx->print = cfg_print;
+ ctx->info = cfg_print;
}
- ctx->error = cfg_error;
- ctx->print = cfg_print;
- ctx->info = cfg_print;
-
n = 0;
line = NULL;
retval = CMD_RETURN_NORMAL;