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.
This commit is contained in:
Tim Janik 1998-08-09 13:13:12 +00:00
parent c36aa81e1b
commit af0977e8e7
2 changed files with 13 additions and 14 deletions

View File

@ -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);
@ -221,6 +221,8 @@ g_module_close (GModule *module)
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);

View File

@ -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;