split off and compile util.c separately
[project/uci.git] / libuci.c
index a3dde2e..5b22ef1 100644 (file)
--- a/libuci.c
+++ b/libuci.c
@@ -40,14 +40,11 @@ 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"
 
 /* exported functions */
 struct uci_context *uci_alloc_context(void)
@@ -55,6 +52,9 @@ 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);
@@ -114,7 +114,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;