From ce36e5fb2ba544ee0b5be2a7a645ffa20c08ceab Mon Sep 17 00:00:00 2001 From: twy_2000 Date: Wed, 1 Jul 2020 15:00:52 +0800 Subject: [PATCH] dawn_uci: no need uci_alloc_context on each uci_set_network call --- src/utils/dawn_uci.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/utils/dawn_uci.c b/src/utils/dawn_uci.c index 15e1cf2..4de4e27 100644 --- a/src/utils/dawn_uci.c +++ b/src/utils/dawn_uci.c @@ -200,6 +200,7 @@ int uci_init() { ctx->flags &= ~UCI_FLAG_STRICT; } else { + ctx->flags &= ~UCI_FLAG_STRICT; // shouldn't happen? uci_pkg = uci_lookup_package(ctx, "dawn"); if (uci_pkg) @@ -226,9 +227,13 @@ int uci_set_network(char* uci_cmd) { struct uci_ptr ptr; int ret = UCI_OK; - struct uci_context *ctx; + struct uci_context *ctx = uci_ctx; + + if (!ctx) { + ctx = uci_alloc_context(); + uci_ctx = ctx; + } - ctx = uci_alloc_context(); ctx->flags |= UCI_FLAG_STRICT; if (uci_lookup_ptr(ctx, &ptr, uci_cmd, 1) != UCI_OK) {