Merge branch 'cherry-pick-327-gmodule-cleanup' into 'master'

gmodule: change _g_module_close to only take a handle.

See merge request GNOME/glib!1283
This commit is contained in:
Philip Withnall 2020-02-24 10:32:18 +00:00
commit 46f91a88b6
4 changed files with 10 additions and 32 deletions

View File

@ -141,19 +141,10 @@ _g_module_self (void)
} }
static void static void
_g_module_close (gpointer handle, _g_module_close (gpointer handle)
gboolean is_unref)
{ {
/* are there any systems out there that have dlopen()/dlclose() if (dlclose (handle) != 0)
* without a reference count implementation? g_module_set_error (fetch_dlerror (TRUE));
*/
is_unref |= 1;
if (is_unref)
{
if (dlclose (handle) != 0)
g_module_set_error (fetch_dlerror (TRUE));
}
} }
static gpointer static gpointer

View File

@ -131,21 +131,11 @@ _g_module_self (void)
} }
static void static void
_g_module_close (gpointer handle, _g_module_close (gpointer handle)
gboolean is_unref)
{ {
/* are there any systems out there that have dlopen()/dlclose()
* without a reference count implementation?
*
* See above for the Android special case
*/
#if defined(__BIONIC__) #if defined(__BIONIC__)
is_unref = (handle != RTLD_DEFAULT); if (handle != RTLD_DEFAULT)
#else
is_unref |= 1;
#endif #endif
if (is_unref)
{ {
if (dlclose (handle) != 0) if (dlclose (handle) != 0)
g_module_set_error (fetch_dlerror (TRUE)); g_module_set_error (fetch_dlerror (TRUE));

View File

@ -113,8 +113,7 @@ _g_module_self (void)
} }
static void static void
_g_module_close (gpointer handle, _g_module_close (gpointer handle)
gboolean is_unref)
{ {
if (handle != null_module_handle) if (handle != null_module_handle)
if (!FreeLibrary (handle)) if (!FreeLibrary (handle))

View File

@ -207,8 +207,7 @@ struct _GModule
static gpointer _g_module_open (const gchar *file_name, static gpointer _g_module_open (const gchar *file_name,
gboolean bind_lazy, gboolean bind_lazy,
gboolean bind_local); gboolean bind_local);
static void _g_module_close (gpointer handle, static void _g_module_close (gpointer handle);
gboolean is_unref);
static gpointer _g_module_self (void); static gpointer _g_module_self (void);
static gpointer _g_module_symbol (gpointer handle, static gpointer _g_module_symbol (gpointer handle,
const gchar *symbol_name); const gchar *symbol_name);
@ -297,8 +296,7 @@ _g_module_open (const gchar *file_name,
return NULL; return NULL;
} }
static void static void
_g_module_close (gpointer handle, _g_module_close (gpointer handle)
gboolean is_unref)
{ {
} }
static gpointer static gpointer
@ -615,7 +613,7 @@ g_module_open (const gchar *file_name,
module = g_module_find_by_handle (handle); module = g_module_find_by_handle (handle);
if (module) if (module)
{ {
_g_module_close (module->handle, TRUE); _g_module_close (module->handle);
module->ref_count++; module->ref_count++;
g_module_set_error (NULL); g_module_set_error (NULL);
@ -721,7 +719,7 @@ g_module_close (GModule *module)
} }
module->next = NULL; module->next = NULL;
_g_module_close (module->handle, FALSE); _g_module_close (module->handle);
g_free (module->file_name); g_free (module->file_name);
g_free (module); g_free (module);
} }