mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-09-27 17:52:58 +02:00
do not return NULL symbols.
Wed Mar 1 05:34:47 2000 Tim Janik <timj@gtk.org> * gmodule-beos.c (_g_module_symbol): do not return NULL symbols. * gmodule-os2.c: removed NetBSD specific defines. (_g_module_self): set an error message for unsupported behaviour. * gmodule-beos.c: many coding style fixups. (_g_module_open): (_g_module_self): (_g_module_close): (_g_module_symbol): bunch of memory leaks plugged. * gmodule-dl.c: make sure the error message returned from dlerror() is always != NULL, by using a wrapper function fetch_dlerror(). based on a patch to fix _g_module_symbol() for NetBSD from Scott Presnell <srp@zgi.com>. * gmodule-dld.c: minor indentation. * gmodule-win32.c: minor cleanups. * merges from glib-1-2.
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
/* GMODULE - GLIB wrapper code for dynamic module loading
|
/* GMODULE - GLIB wrapper code for dynamic module loading
|
||||||
* Copyright (C) 1998 Tim Janik
|
* Copyright (C) 1998, 2000 Tim Janik
|
||||||
|
*
|
||||||
|
* WIN32 GMODULE implementation
|
||||||
* Copyright (C) 1998 Tor Lillqvist
|
* Copyright (C) 1998 Tor Lillqvist
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
@@ -42,9 +44,9 @@ _g_module_open (const gchar *file_name,
|
|||||||
handle = LoadLibrary (file_name);
|
handle = LoadLibrary (file_name);
|
||||||
if (!handle)
|
if (!handle)
|
||||||
{
|
{
|
||||||
char error[100];
|
gchar error[100];
|
||||||
FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError (),
|
|
||||||
0, error, sizeof (error), NULL);
|
sprintf (error, "Error code %d", GetLastError ());
|
||||||
g_module_set_error (error);
|
g_module_set_error (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,9 +61,9 @@ _g_module_self (void)
|
|||||||
handle = GetModuleHandle (NULL);
|
handle = GetModuleHandle (NULL);
|
||||||
if (!handle)
|
if (!handle)
|
||||||
{
|
{
|
||||||
char error[100];
|
gchar error[100];
|
||||||
FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError (),
|
|
||||||
0, error, sizeof (error), NULL);
|
sprintf (error, "Error code %d", GetLastError ());
|
||||||
g_module_set_error (error);
|
g_module_set_error (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,9 +76,9 @@ _g_module_close (gpointer handle,
|
|||||||
{
|
{
|
||||||
if (!FreeLibrary (handle))
|
if (!FreeLibrary (handle))
|
||||||
{
|
{
|
||||||
char error[100];
|
gchar error[100];
|
||||||
FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError (),
|
|
||||||
0, error, sizeof (error), NULL);
|
sprintf (error, "Error code %d", GetLastError ());
|
||||||
g_module_set_error (error);
|
g_module_set_error (error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,11 +92,12 @@ _g_module_symbol (gpointer handle,
|
|||||||
p = GetProcAddress (handle, symbol_name);
|
p = GetProcAddress (handle, symbol_name);
|
||||||
if (!p)
|
if (!p)
|
||||||
{
|
{
|
||||||
char error[100];
|
gchar error[100];
|
||||||
FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError (),
|
|
||||||
0, error, sizeof (error), NULL);
|
sprintf (error, "Error code %d", GetLastError ());
|
||||||
g_module_set_error (error);
|
g_module_set_error (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -134,10 +134,6 @@ g_module_set_error (const gchar *error)
|
|||||||
#include "gmodule-dld.c"
|
#include "gmodule-dld.c"
|
||||||
#elif (G_MODULE_IMPL == G_MODULE_IMPL_WIN32)
|
#elif (G_MODULE_IMPL == G_MODULE_IMPL_WIN32)
|
||||||
#include "gmodule-win32.c"
|
#include "gmodule-win32.c"
|
||||||
#elif (G_MODULE_IMPL == G_MODULE_IMPL_OS2)
|
|
||||||
#include "gmodule-os2.c"
|
|
||||||
#elif (G_MODULE_IMPL == G_MODULE_IMPL_BEOS)
|
|
||||||
#include "gmodule-beos.c"
|
|
||||||
#else
|
#else
|
||||||
#undef SUPPORT_OR_RETURN
|
#undef SUPPORT_OR_RETURN
|
||||||
#define SUPPORT_OR_RETURN(rv) { g_module_set_error ("dynamic modules are " \
|
#define SUPPORT_OR_RETURN(rv) { g_module_set_error ("dynamic modules are " \
|
||||||
@@ -172,6 +168,17 @@ _g_module_build_path (const gchar *directory,
|
|||||||
}
|
}
|
||||||
#endif /* no implementation */
|
#endif /* no implementation */
|
||||||
|
|
||||||
|
#if defined (NATIVE_WIN32) && defined (__LCC__)
|
||||||
|
int __stdcall
|
||||||
|
LibMain (void *hinstDll,
|
||||||
|
unsigned long dwReason,
|
||||||
|
void *reserved)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif /* NATIVE_WIN32 && __LCC__ */
|
||||||
|
|
||||||
|
|
||||||
/* --- functions --- */
|
/* --- functions --- */
|
||||||
gboolean
|
gboolean
|
||||||
g_module_supported (void)
|
g_module_supported (void)
|
||||||
@@ -256,7 +263,6 @@ g_module_open (const gchar *file_name,
|
|||||||
|
|
||||||
/* check initialization */
|
/* check initialization */
|
||||||
if (g_module_symbol (module, "g_module_check_init", (gpointer) &check_init))
|
if (g_module_symbol (module, "g_module_check_init", (gpointer) &check_init))
|
||||||
if (check_init)
|
|
||||||
check_failed = check_init (module);
|
check_failed = check_init (module);
|
||||||
|
|
||||||
/* we don't call unload() if the initialization check failed. */
|
/* we don't call unload() if the initialization check failed. */
|
||||||
@@ -376,7 +382,7 @@ g_module_symbol (GModule *module,
|
|||||||
*symbol = _g_module_symbol (module->handle, symbol_name);
|
*symbol = _g_module_symbol (module->handle, symbol_name);
|
||||||
#endif /* !G_MODULE_NEED_USCORE */
|
#endif /* !G_MODULE_NEED_USCORE */
|
||||||
|
|
||||||
module_error = g_module_error();
|
module_error = g_module_error ();
|
||||||
if (module_error)
|
if (module_error)
|
||||||
{
|
{
|
||||||
gchar *error;
|
gchar *error;
|
||||||
@@ -385,6 +391,7 @@ g_module_symbol (GModule *module,
|
|||||||
g_module_set_error (error);
|
g_module_set_error (error);
|
||||||
g_free (error);
|
g_free (error);
|
||||||
*symbol = NULL;
|
*symbol = NULL;
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -27,6 +27,16 @@
|
|||||||
#include <gmodule.h>
|
#include <gmodule.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#if defined (NATIVE_WIN32) && defined (__LCC__)
|
||||||
|
int __stdcall
|
||||||
|
LibMain(void *hinstDll,
|
||||||
|
unsigned long dwReason,
|
||||||
|
void *reserved)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif /* NATIVE_WIN32 && __LCC__ */
|
||||||
|
|
||||||
G_MODULE_EXPORT void
|
G_MODULE_EXPORT void
|
||||||
gplugin_a_func (void)
|
gplugin_a_func (void)
|
||||||
{
|
{
|
||||||
@@ -54,7 +64,7 @@ gplugin_say_boo_func (void)
|
|||||||
G_MODULE_EXPORT void
|
G_MODULE_EXPORT void
|
||||||
gplugin_a_module_func (GModule *module)
|
gplugin_a_module_func (GModule *module)
|
||||||
{
|
{
|
||||||
void(*f)(void) = NULL;
|
void (*f) (void) = NULL;
|
||||||
gchar *string;
|
gchar *string;
|
||||||
|
|
||||||
string = "gplugin_say_boo_func";
|
string = "gplugin_say_boo_func";
|
||||||
|
@@ -26,6 +26,16 @@
|
|||||||
|
|
||||||
#include <gmodule.h>
|
#include <gmodule.h>
|
||||||
|
|
||||||
|
#if defined (NATIVE_WIN32) && defined (__LCC__)
|
||||||
|
int __stdcall
|
||||||
|
LibMain(void *hinstDll,
|
||||||
|
unsigned long dwReason,
|
||||||
|
void *reserved)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif /* NATIVE_WIN32 && __LCC__ */
|
||||||
|
|
||||||
G_MODULE_EXPORT const gchar*
|
G_MODULE_EXPORT const gchar*
|
||||||
g_module_check_init (GModule *module)
|
g_module_check_init (GModule *module)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user