X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=libuci.c;h=995d39dad7fdf952eec0aa49b6af92cfcb5ff8cc;hb=e7e26e750772259ae89558277a7ecec01feb24fa;hp=a3dde2edc4adedd320577cc138a26472c586bcb2;hpb=476db477246a1438f3b2535bf37ab7f9130827c8;p=project%2Fuci.git diff --git a/libuci.c b/libuci.c index a3dde2e..995d39d 100644 --- a/libuci.c +++ b/libuci.c @@ -9,7 +9,7 @@ * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * GNU Lesser General Public License for more details. */ /* @@ -26,9 +26,6 @@ #include #include "uci.h" -static const char *uci_confdir = UCI_CONFDIR; -static const char *uci_savedir = UCI_SAVEDIR; - static const char *uci_errstr[] = { [UCI_OK] = "Success", [UCI_ERR_MEM] = "Out of memory", @@ -40,14 +37,13 @@ static const char *uci_errstr[] = { [UCI_ERR_UNKNOWN] = "Unknown error", }; -static void uci_cleanup(struct uci_context *ctx); static void uci_unload_plugin(struct uci_context *ctx, struct uci_plugin *p); #include "uci_internal.h" -#include "util.c" #include "list.c" -#include "history.c" -#include "file.c" + +__private const char *uci_confdir = UCI_CONFDIR; +__private const char *uci_savedir = UCI_SAVEDIR; /* exported functions */ struct uci_context *uci_alloc_context(void) @@ -55,13 +51,16 @@ struct uci_context *uci_alloc_context(void) struct uci_context *ctx; ctx = (struct uci_context *) malloc(sizeof(struct uci_context)); + if (!ctx) + return NULL; + memset(ctx, 0, sizeof(struct uci_context)); uci_list_init(&ctx->root); - uci_list_init(&ctx->history_path); + uci_list_init(&ctx->delta_path); uci_list_init(&ctx->backends); uci_list_init(&ctx->hooks); uci_list_init(&ctx->plugins); - ctx->flags = UCI_FLAG_STRICT | UCI_FLAG_SAVED_HISTORY; + ctx->flags = UCI_FLAG_STRICT | UCI_FLAG_SAVED_DELTA; ctx->confdir = (char *) uci_confdir; ctx->savedir = (char *) uci_savedir; @@ -87,7 +86,7 @@ void uci_free_context(struct uci_context *ctx) struct uci_package *p = uci_to_package(e); uci_free_package(&p); } - uci_foreach_element_safe(&ctx->history_path, tmp, e) { + uci_foreach_element_safe(&ctx->delta_path, tmp, e) { uci_free_element(e); } UCI_TRAP_RESTORE(ctx); @@ -114,7 +113,7 @@ int uci_set_confdir(struct uci_context *ctx, const char *dir) return 0; } -static void uci_cleanup(struct uci_context *ctx) +__private void uci_cleanup(struct uci_context *ctx) { struct uci_parse_context *pctx; @@ -326,6 +325,7 @@ int uci_remove_hook(struct uci_context *ctx, const struct uci_hook_ops *ops) struct uci_hook *h = uci_to_hook(e); if (h->ops == ops) { uci_list_del(&e->list); + uci_free_element(e); return 0; } }