From c57e7c394391fe559f3d67562e88ff90d6ad901f Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Tue, 12 Feb 2008 11:02:00 +0100 Subject: [PATCH] fold uci_file_cleanup into uci_cleanup --- file.c | 20 -------------------- libuci.c | 22 +++++++++++++++++++++- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/file.c b/file.c index 553e519..7049b33 100644 --- a/file.c +++ b/file.c @@ -30,26 +30,6 @@ */ static void uci_file_cleanup(struct uci_context *ctx) { - struct uci_parse_context *pctx; - - if (ctx->buf) { - free(ctx->buf); - ctx->buf = NULL; - ctx->bufsz = 0; - } - - pctx = ctx->pctx; - if (!pctx) - return; - - ctx->pctx = NULL; - if (pctx->package) - uci_free_package(&pctx->package); - - if (pctx->buf) - free(pctx->buf); - - free(pctx); } diff --git a/libuci.c b/libuci.c index 7805d74..118289b 100644 --- a/libuci.c +++ b/libuci.c @@ -104,8 +104,28 @@ int uci_set_confdir(struct uci_context *ctx, const char *dir) int uci_cleanup(struct uci_context *ctx) { + struct uci_parse_context *pctx; UCI_HANDLE_ERR(ctx); - uci_file_cleanup(ctx); + + if (ctx->buf) { + free(ctx->buf); + ctx->buf = NULL; + ctx->bufsz = 0; + } + + pctx = ctx->pctx; + if (!pctx) + goto done; + + ctx->pctx = NULL; + if (pctx->package) + uci_free_package(&pctx->package); + + if (pctx->buf) + free(pctx->buf); + + free(pctx); +done: return 0; } -- 2.25.1