summaryrefslogtreecommitdiffhomepage
path: root/lib/uci.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-09-20 22:20:54 +0200
committerJo-Philipp Wich <jo@mein.io>2020-09-20 22:20:54 +0200
commit2c6ce788d039ac5aed91955b0be5640bf1318ef5 (patch)
tree6e78dbb9113d67b3a210a5d1c9630229d4c8ab58 /lib/uci.c
parent37daee3aaad91536fc57e01e50f44319ee494ee3 (diff)
treewide: rework extended type handling
Register prototype object directly together with the type instead of setting it manually whenever an extended type value is instantiated. This also allows freeing the various prototype objects in dlopened modules. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'lib/uci.c')
-rw-r--r--lib/uci.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/uci.c b/lib/uci.c
index 8f7ffce..3cefd2f 100644
--- a/lib/uci.c
+++ b/lib/uci.c
@@ -23,8 +23,6 @@
static const struct ut_ops *ops;
-static struct json_object *uci_proto;
-
static int last_error = 0;
enum pkg_cmd {
@@ -105,7 +103,7 @@ ut_uci_cursor(struct ut_state *s, uint32_t off, struct json_object *args)
err_return(UCI_ERR_MEM);
}
- return ops->set_type(co, uci_proto, "uci.cursor", c);
+ return ops->set_type(co, "uci.cursor", c);
}
@@ -1015,11 +1013,13 @@ static void close_uci(void *ud) {
void ut_module_init(const struct ut_ops *ut, struct ut_state *s, struct json_object *scope)
{
- ops = ut;
- ops->register_type("uci.cursor", close_uci);
+ struct json_object *uci_proto;
+ ops = ut;
uci_proto = ops->new_object(NULL);
register_functions(ops, global_fns, scope);
register_functions(ops, cursor_fns, uci_proto);
+
+ ops->register_type("uci.cursor", uci_proto, close_uci);
}