int len;
/* skip any of the prefixes.. */
- while (*prefixes != NULL) {
- len = strlen(*prefixes);
- if (strncmp(name, *prefixes, len) == 0 && name[len] == '_') {
- name += len+1;
- break;
+ if (prefixes != NULL) {
+ while (*prefixes != NULL) {
+ len = strlen(*prefixes);
+ if (strncmp(name, *prefixes, len) == 0 &&
+ name[len] == '_') {
+ name += len+1;
+ break;
+ }
+ prefixes++;
}
- prefixes++;
}
/* skip the _core part */
strcmp(name+rootlen, "_core") == 0)
return g_strdup("core");
- if (namelen+1 > rootlen && name[namelen-rootlen-1] == '_' &&
+ if (namelen > rootlen && name[namelen-rootlen-1] == '_' &&
strcmp(name+namelen-rootlen, root) == 0)
return g_strndup(name, namelen-rootlen-1);
GModule *gmodule;
MODULE_REC *module;
MODULE_FILE_REC *rec;
+ gpointer value1, value2;
char *initfunc, *deinitfunc;
int found;
/* get the module's init() and deinit() functions */
initfunc = module_get_func(rootmodule, submodule, "init");
deinitfunc = module_get_func(rootmodule, submodule, "deinit");
- found = g_module_symbol(gmodule, initfunc, (gpointer *) &module_init) &&
- g_module_symbol(gmodule, deinitfunc, (gpointer *) &module_deinit);
+ found = g_module_symbol(gmodule, initfunc, &value1) &&
+ g_module_symbol(gmodule, deinitfunc, &value2);
g_free(initfunc);
g_free(deinitfunc);
+ module_init = value1;
+ module_deinit = value2;
+
if (!found) {
module_error(MODULE_ERROR_INVALID, NULL,
rootmodule, submodule);
g_module_close(file->gmodule);
}
+#else /* !HAVE_GMODULE - modules are not supported */
+
+int module_load(const char *path, char **prefixes)
+{
+ return FALSE;
+}
+
+#endif
+
void module_file_unload(MODULE_FILE_REC *file)
{
MODULE_REC *root;
if (file->initialized)
signal_emit("module unloaded", 2, file->root, file);
+#ifdef HAVE_GMODULE
if (file->gmodule != NULL)
module_file_deinit_gmodule(file);
+#endif
g_free(file->name);
g_free(file->defined_module_name);
g_free(module->name);
g_free(module);
}
-
-#else /* !HAVE_GMODULE - modules are not supported */
-
-int module_load(const char *path, char **prefixes)
-{
- return FALSE;
-}
-
-void module_unload(MODULE_REC *module)
-{
-}
-
-#endif