summaryrefslogtreecommitdiff
path: root/gmodule
diff options
context:
space:
mode:
authorTim Janik <timj@src.gnome.org>1998-08-09 13:13:12 +0000
committerTim Janik <timj@src.gnome.org>1998-08-09 13:13:12 +0000
commitaf0977e8e7c384c0fff179a3222ba257695e3a8f (patch)
tree3e37e20c4f4b002043a6da704edd683ae69dcef9 /gmodule
parentc36aa81e1be8a457478effe71a8e1e4edb4b8051 (diff)
hm, fixup call sequences for check_init() and de_init().
we need to have internal structures in a sane state before we call external functions.
Diffstat (limited to 'gmodule')
-rw-r--r--gmodule/gmodule.c25
-rw-r--r--gmodule/libgplugin_a.c2
2 files changed, 13 insertions, 14 deletions
diff --git a/gmodule/gmodule.c b/gmodule/gmodule.c
index a4f31c13d..a883ace18 100644
--- a/gmodule/gmodule.c
+++ b/gmodule/gmodule.c
@@ -66,6 +66,9 @@ g_module_find_by_handle (gpointer handle)
{
GModule *module;
+ if (main_module && main_module->handle == handle)
+ return main_module;
+
for (module = modules; module; module = module->next)
if (handle == module->handle)
return module;
@@ -180,22 +183,19 @@ g_module_open (const gchar *file_name,
module = g_new (GModule, 1);
module->file_name = g_strdup (file_name);
module->handle = handle;
- module->ref_count = 0;
+ module->ref_count = 1;
module->de_init = NULL;
- module->next = NULL;
+ module->next = modules;
+ modules = module;
/* check initialization */
if (g_module_symbol (module, "g_module_check_init", &check_init))
check_failed = check_init (module);
- /* should call de_init() on failed initializations also? */
+ /* we don't call de_init() if the initialization check failed. */
if (!check_failed)
g_module_symbol (module, "g_module_de_init", &module->de_init);
- module->ref_count += 1;
- module->next = modules;
- modules = module;
-
if (check_failed)
{
g_module_close (module);
@@ -214,13 +214,15 @@ gboolean
g_module_close (GModule *module)
{
CHECK_ERROR (FALSE);
-
+
g_return_val_if_fail (module != NULL, FALSE);
g_return_val_if_fail (module->ref_count > 0, FALSE);
-
+
if (module != main_module)
module->ref_count--;
-
+
+ if (!module->ref_count && module->de_init)
+ module->de_init (module);
if (!module->ref_count)
{
GModule *last;
@@ -243,9 +245,6 @@ g_module_close (GModule *module)
}
module->next = NULL;
- if (module->de_init)
- module->de_init (module);
-
_g_module_close (&module->handle, FALSE);
g_free (module->file_name);
diff --git a/gmodule/libgplugin_a.c b/gmodule/libgplugin_a.c
index 312997886..1ed32b324 100644
--- a/gmodule/libgplugin_a.c
+++ b/gmodule/libgplugin_a.c
@@ -42,7 +42,7 @@ gplugin_say_boo_func (void)
g_print ("GPluginA: BOOH!\n");
}
-void
+G_MODULE_EXPORT void
gplugin_a_module_func (GModule *module)
{
void(*f)(void) = NULL;