lua: include /opt/local/lib and /opt/local/include in the search path on mac os x
[project/uci.git] / libuci.c
index 1a09fc7..4c2bf96 100644 (file)
--- 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 <glob.h>
 #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",
@@ -44,7 +41,9 @@ static void uci_unload_plugin(struct uci_context *ctx, struct uci_plugin *p);
 
 #include "uci_internal.h"
 #include "list.c"
-#include "delta.c"
+
+__private const char *uci_confdir = UCI_CONFDIR;
+__private const char *uci_savedir = UCI_SAVEDIR;
 
 /* exported functions */
 struct uci_context *uci_alloc_context(void)
@@ -178,7 +177,7 @@ uci_get_errorstr(struct uci_context *ctx, char **dest, const char *prefix)
        if (dest) {
                err = asprintf(dest, format,
                        (prefix ? prefix : ""), (prefix ? ": " : ""),
-                       (ctx->func ? ctx->func : ""), (ctx->func ? ": " : ""),
+                       (ctx && ctx->func ? ctx->func : ""), (ctx && ctx->func ? ": " : ""),
                        uci_errstr[err],
                        error_info);
                if (err < 0)
@@ -187,7 +186,7 @@ uci_get_errorstr(struct uci_context *ctx, char **dest, const char *prefix)
                strcat(error_info, "\n");
                fprintf(stderr, format,
                        (prefix ? prefix : ""), (prefix ? ": " : ""),
-                       (ctx->func ? ctx->func : ""), (ctx->func ? ": " : ""),
+                       (ctx && ctx->func ? ctx->func : ""), (ctx && ctx->func ? ": " : ""),
                        uci_errstr[err],
                        error_info);
        }
@@ -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;
                }
        }