summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLukáš Ondráček <lukas.ondracek@nic.cz>2025-01-02 14:38:53 +0100
committerLukáš Ondráček <lukas.ondracek@nic.cz>2025-01-02 14:38:53 +0100
commita01dbeba1852a6cd71e81fb99f65e0810ec0046f (patch)
tree2347fb0d57801f13279af9f4c1435def5af50990 /lib
parentdaemon/defer: fix configuration reload (diff)
parentMerge branch 'kresctl-tab-completion' into 'master' (diff)
downloadknot-resolver-a01dbeba1852a6cd71e81fb99f65e0810ec0046f.tar.xz
knot-resolver-a01dbeba1852a6cd71e81fb99f65e0810ec0046f.zip
Merge branch 'master' into defer-wip
Diffstat (limited to 'lib')
-rw-r--r--lib/module.c6
-rw-r--r--lib/module.h2
2 files changed, 4 insertions, 4 deletions
diff --git a/lib/module.c b/lib/module.c
index 79219d3a..df9a1f5e 100644
--- a/lib/module.c
+++ b/lib/module.c
@@ -103,10 +103,8 @@ int kr_module_load(struct kr_module *module, const char *name, const char *path)
return kr_error(EINVAL);
}
- /* Initialize, keep userdata */
- void *data = module->data;
+ /* Initialize */
memset(module, 0, sizeof(struct kr_module));
- module->data = data;
module->name = strdup(name);
if (module->name == NULL) {
return kr_error(ENOMEM);
@@ -123,6 +121,8 @@ int kr_module_load(struct kr_module *module, const char *name, const char *path)
ret = module->init(module);
}
if (ret != 0) {
+ /* Avoid calling deinit() as init() wasn't called or failed. */
+ module->deinit = NULL;
kr_module_unload(module);
}
diff --git a/lib/module.h b/lib/module.h
index 507b2df1..4dd5a490 100644
--- a/lib/module.h
+++ b/lib/module.h
@@ -86,7 +86,7 @@ struct kr_prop {
/**
* Load a C module instance into memory. And call its init().
*
- * @param module module structure. Will be overwritten except for ->data on success.
+ * @param module module structure. Will be overwritten.
* @param name module name
* @param path module search path
* @return 0 or an error