mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-09 20:35:49 +01:00
fixed errernerous code wrt to thread specific error string allocation
Wed Feb 10 07:56:33 1999 Tim Janik <timj@gtk.org> * gmodule.c (g_module_error): fixed errernerous code wrt to thread specific error string allocation handling. Wed Feb 10 06:20:30 1999 Tim Janik <timj@gtk.org> * gmutex.c (g_static_private_set): invoke destroy notifier when overwriting values, initialize new array fields with NULL. (g_static_private_free_data): do not skip destroy notification for data == NULL. * gutils.c (g_direct_equal): compare pointer values directly instead of just their guint values which is a loosing conversion for sizeof(gpointer)==8 systems. (g_get_any_init): restructured code so we don't use endless loops like while (1), which boil down to an ugly alias for goto. strip ,.* from the real name.
This commit is contained in:
parent
6c79947722
commit
a8ff1b4fce
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
|||||||
|
Wed Feb 10 06:20:30 1999 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gmutex.c (g_static_private_set): invoke destroy notifier when
|
||||||
|
overwriting values, initialize new array fields with NULL.
|
||||||
|
(g_static_private_free_data): do not skip destroy notification for
|
||||||
|
data == NULL.
|
||||||
|
|
||||||
|
* gutils.c (g_direct_equal): compare pointer values directly instead
|
||||||
|
of just their guint values which is a loosing conversion for
|
||||||
|
sizeof(gpointer)==8 systems.
|
||||||
|
(g_get_any_init): restructured code so we don't use endless loops like
|
||||||
|
while (1), which boil down to an ugly alias for goto.
|
||||||
|
strip ,.* from the real name.
|
||||||
|
|
||||||
February 9, 1999 sopwith@redhat.com
|
February 9, 1999 sopwith@redhat.com
|
||||||
|
|
||||||
. glist.c, gnode.c, gslist.c: allocate pools of 128 items instead
|
. glist.c, gnode.c, gslist.c: allocate pools of 128 items instead
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
Wed Feb 10 06:20:30 1999 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gmutex.c (g_static_private_set): invoke destroy notifier when
|
||||||
|
overwriting values, initialize new array fields with NULL.
|
||||||
|
(g_static_private_free_data): do not skip destroy notification for
|
||||||
|
data == NULL.
|
||||||
|
|
||||||
|
* gutils.c (g_direct_equal): compare pointer values directly instead
|
||||||
|
of just their guint values which is a loosing conversion for
|
||||||
|
sizeof(gpointer)==8 systems.
|
||||||
|
(g_get_any_init): restructured code so we don't use endless loops like
|
||||||
|
while (1), which boil down to an ugly alias for goto.
|
||||||
|
strip ,.* from the real name.
|
||||||
|
|
||||||
February 9, 1999 sopwith@redhat.com
|
February 9, 1999 sopwith@redhat.com
|
||||||
|
|
||||||
. glist.c, gnode.c, gslist.c: allocate pools of 128 items instead
|
. glist.c, gnode.c, gslist.c: allocate pools of 128 items instead
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
Wed Feb 10 06:20:30 1999 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gmutex.c (g_static_private_set): invoke destroy notifier when
|
||||||
|
overwriting values, initialize new array fields with NULL.
|
||||||
|
(g_static_private_free_data): do not skip destroy notification for
|
||||||
|
data == NULL.
|
||||||
|
|
||||||
|
* gutils.c (g_direct_equal): compare pointer values directly instead
|
||||||
|
of just their guint values which is a loosing conversion for
|
||||||
|
sizeof(gpointer)==8 systems.
|
||||||
|
(g_get_any_init): restructured code so we don't use endless loops like
|
||||||
|
while (1), which boil down to an ugly alias for goto.
|
||||||
|
strip ,.* from the real name.
|
||||||
|
|
||||||
February 9, 1999 sopwith@redhat.com
|
February 9, 1999 sopwith@redhat.com
|
||||||
|
|
||||||
. glist.c, gnode.c, gslist.c: allocate pools of 128 items instead
|
. glist.c, gnode.c, gslist.c: allocate pools of 128 items instead
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
Wed Feb 10 06:20:30 1999 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gmutex.c (g_static_private_set): invoke destroy notifier when
|
||||||
|
overwriting values, initialize new array fields with NULL.
|
||||||
|
(g_static_private_free_data): do not skip destroy notification for
|
||||||
|
data == NULL.
|
||||||
|
|
||||||
|
* gutils.c (g_direct_equal): compare pointer values directly instead
|
||||||
|
of just their guint values which is a loosing conversion for
|
||||||
|
sizeof(gpointer)==8 systems.
|
||||||
|
(g_get_any_init): restructured code so we don't use endless loops like
|
||||||
|
while (1), which boil down to an ugly alias for goto.
|
||||||
|
strip ,.* from the real name.
|
||||||
|
|
||||||
February 9, 1999 sopwith@redhat.com
|
February 9, 1999 sopwith@redhat.com
|
||||||
|
|
||||||
. glist.c, gnode.c, gslist.c: allocate pools of 128 items instead
|
. glist.c, gnode.c, gslist.c: allocate pools of 128 items instead
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
Wed Feb 10 06:20:30 1999 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gmutex.c (g_static_private_set): invoke destroy notifier when
|
||||||
|
overwriting values, initialize new array fields with NULL.
|
||||||
|
(g_static_private_free_data): do not skip destroy notification for
|
||||||
|
data == NULL.
|
||||||
|
|
||||||
|
* gutils.c (g_direct_equal): compare pointer values directly instead
|
||||||
|
of just their guint values which is a loosing conversion for
|
||||||
|
sizeof(gpointer)==8 systems.
|
||||||
|
(g_get_any_init): restructured code so we don't use endless loops like
|
||||||
|
while (1), which boil down to an ugly alias for goto.
|
||||||
|
strip ,.* from the real name.
|
||||||
|
|
||||||
February 9, 1999 sopwith@redhat.com
|
February 9, 1999 sopwith@redhat.com
|
||||||
|
|
||||||
. glist.c, gnode.c, gslist.c: allocate pools of 128 items instead
|
. glist.c, gnode.c, gslist.c: allocate pools of 128 items instead
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
Wed Feb 10 06:20:30 1999 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gmutex.c (g_static_private_set): invoke destroy notifier when
|
||||||
|
overwriting values, initialize new array fields with NULL.
|
||||||
|
(g_static_private_free_data): do not skip destroy notification for
|
||||||
|
data == NULL.
|
||||||
|
|
||||||
|
* gutils.c (g_direct_equal): compare pointer values directly instead
|
||||||
|
of just their guint values which is a loosing conversion for
|
||||||
|
sizeof(gpointer)==8 systems.
|
||||||
|
(g_get_any_init): restructured code so we don't use endless loops like
|
||||||
|
while (1), which boil down to an ugly alias for goto.
|
||||||
|
strip ,.* from the real name.
|
||||||
|
|
||||||
February 9, 1999 sopwith@redhat.com
|
February 9, 1999 sopwith@redhat.com
|
||||||
|
|
||||||
. glist.c, gnode.c, gslist.c: allocate pools of 128 items instead
|
. glist.c, gnode.c, gslist.c: allocate pools of 128 items instead
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
Wed Feb 10 06:20:30 1999 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gmutex.c (g_static_private_set): invoke destroy notifier when
|
||||||
|
overwriting values, initialize new array fields with NULL.
|
||||||
|
(g_static_private_free_data): do not skip destroy notification for
|
||||||
|
data == NULL.
|
||||||
|
|
||||||
|
* gutils.c (g_direct_equal): compare pointer values directly instead
|
||||||
|
of just their guint values which is a loosing conversion for
|
||||||
|
sizeof(gpointer)==8 systems.
|
||||||
|
(g_get_any_init): restructured code so we don't use endless loops like
|
||||||
|
while (1), which boil down to an ugly alias for goto.
|
||||||
|
strip ,.* from the real name.
|
||||||
|
|
||||||
February 9, 1999 sopwith@redhat.com
|
February 9, 1999 sopwith@redhat.com
|
||||||
|
|
||||||
. glist.c, gnode.c, gslist.c: allocate pools of 128 items instead
|
. glist.c, gnode.c, gslist.c: allocate pools of 128 items instead
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
Wed Feb 10 06:20:30 1999 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gmutex.c (g_static_private_set): invoke destroy notifier when
|
||||||
|
overwriting values, initialize new array fields with NULL.
|
||||||
|
(g_static_private_free_data): do not skip destroy notification for
|
||||||
|
data == NULL.
|
||||||
|
|
||||||
|
* gutils.c (g_direct_equal): compare pointer values directly instead
|
||||||
|
of just their guint values which is a loosing conversion for
|
||||||
|
sizeof(gpointer)==8 systems.
|
||||||
|
(g_get_any_init): restructured code so we don't use endless loops like
|
||||||
|
while (1), which boil down to an ugly alias for goto.
|
||||||
|
strip ,.* from the real name.
|
||||||
|
|
||||||
February 9, 1999 sopwith@redhat.com
|
February 9, 1999 sopwith@redhat.com
|
||||||
|
|
||||||
. glist.c, gnode.c, gslist.c: allocate pools of 128 items instead
|
. glist.c, gnode.c, gslist.c: allocate pools of 128 items instead
|
||||||
|
10
glib.h
10
glib.h
@ -1632,10 +1632,10 @@ void g_string_sprintfa (GString *string,
|
|||||||
* order by moving the last element to the position of the removed
|
* order by moving the last element to the position of the removed
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define g_array_append_val(a,v) g_array_append_vals(a,&v,1)
|
#define g_array_append_val(a,v) g_array_append_vals (a, &v, 1)
|
||||||
#define g_array_prepend_val(a,v) g_array_prepend_vals(a,&v,1)
|
#define g_array_prepend_val(a,v) g_array_prepend_vals (a, &v, 1)
|
||||||
#define g_array_insert_val(a,i,v) g_array_insert_vals(a,i,&v,1)
|
#define g_array_insert_val(a,i,v) g_array_insert_vals (a, i, &v, 1)
|
||||||
#define g_array_index(a,t,i) (((t*)a->data)[i])
|
#define g_array_index(a,t,i) (((t*) (a)->data) [(i)])
|
||||||
|
|
||||||
GArray* g_array_new (gboolean zero_terminated,
|
GArray* g_array_new (gboolean zero_terminated,
|
||||||
gboolean clear,
|
gboolean clear,
|
||||||
@ -1715,6 +1715,8 @@ guint g_int_hash (gconstpointer v);
|
|||||||
/* This "hash" function will just return the key's adress as an
|
/* This "hash" function will just return the key's adress as an
|
||||||
* unsigned integer. Useful for hashing on plain adresses or
|
* unsigned integer. Useful for hashing on plain adresses or
|
||||||
* simple integer values.
|
* simple integer values.
|
||||||
|
* passing NULL into g_hash_table_new() as GHashFunc has the
|
||||||
|
* same effect as passing g_direct_hash().
|
||||||
*/
|
*/
|
||||||
guint g_direct_hash (gconstpointer v);
|
guint g_direct_hash (gconstpointer v);
|
||||||
gint g_direct_equal (gconstpointer v,
|
gint g_direct_equal (gconstpointer v,
|
||||||
|
10
glib/glib.h
10
glib/glib.h
@ -1632,10 +1632,10 @@ void g_string_sprintfa (GString *string,
|
|||||||
* order by moving the last element to the position of the removed
|
* order by moving the last element to the position of the removed
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define g_array_append_val(a,v) g_array_append_vals(a,&v,1)
|
#define g_array_append_val(a,v) g_array_append_vals (a, &v, 1)
|
||||||
#define g_array_prepend_val(a,v) g_array_prepend_vals(a,&v,1)
|
#define g_array_prepend_val(a,v) g_array_prepend_vals (a, &v, 1)
|
||||||
#define g_array_insert_val(a,i,v) g_array_insert_vals(a,i,&v,1)
|
#define g_array_insert_val(a,i,v) g_array_insert_vals (a, i, &v, 1)
|
||||||
#define g_array_index(a,t,i) (((t*)a->data)[i])
|
#define g_array_index(a,t,i) (((t*) (a)->data) [(i)])
|
||||||
|
|
||||||
GArray* g_array_new (gboolean zero_terminated,
|
GArray* g_array_new (gboolean zero_terminated,
|
||||||
gboolean clear,
|
gboolean clear,
|
||||||
@ -1715,6 +1715,8 @@ guint g_int_hash (gconstpointer v);
|
|||||||
/* This "hash" function will just return the key's adress as an
|
/* This "hash" function will just return the key's adress as an
|
||||||
* unsigned integer. Useful for hashing on plain adresses or
|
* unsigned integer. Useful for hashing on plain adresses or
|
||||||
* simple integer values.
|
* simple integer values.
|
||||||
|
* passing NULL into g_hash_table_new() as GHashFunc has the
|
||||||
|
* same effect as passing g_direct_hash().
|
||||||
*/
|
*/
|
||||||
guint g_direct_hash (gconstpointer v);
|
guint g_direct_hash (gconstpointer v);
|
||||||
gint g_direct_equal (gconstpointer v,
|
gint g_direct_equal (gconstpointer v,
|
||||||
|
@ -644,13 +644,14 @@ g_strerror (gint errnum)
|
|||||||
#endif /* NO_SYS_ERRLIST */
|
#endif /* NO_SYS_ERRLIST */
|
||||||
|
|
||||||
msg = g_static_private_get (&msg_private);
|
msg = g_static_private_get (&msg_private);
|
||||||
if( !msg )
|
if (!msg)
|
||||||
{
|
{
|
||||||
msg = g_new( gchar, 64 );
|
msg = g_new (gchar, 64);
|
||||||
g_static_private_set (&msg_private, msg, g_free);
|
g_static_private_set (&msg_private, msg, g_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf (msg, "unknown error (%d)", errnum);
|
sprintf (msg, "unknown error (%d)", errnum);
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -770,13 +771,14 @@ g_strsignal (gint signum)
|
|||||||
#endif /* NO_SYS_SIGLIST */
|
#endif /* NO_SYS_SIGLIST */
|
||||||
|
|
||||||
msg = g_static_private_get (&msg_private);
|
msg = g_static_private_get (&msg_private);
|
||||||
if( !msg )
|
if (!msg)
|
||||||
{
|
{
|
||||||
msg = g_new( gchar, 64 );
|
msg = g_new (gchar, 64);
|
||||||
g_static_private_set (&msg_private, msg, g_free);
|
g_static_private_set (&msg_private, msg, g_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf (msg, "unknown signal (%d)", signum);
|
sprintf (msg, "unknown signal (%d)", signum);
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,7 +401,7 @@ g_get_any_init (void)
|
|||||||
g_tmp_dir[k-1] = '\0';
|
g_tmp_dir[k-1] = '\0';
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!g_tmp_dir)
|
if (!g_tmp_dir)
|
||||||
{
|
{
|
||||||
#ifndef NATIVE_WIN32
|
#ifndef NATIVE_WIN32
|
||||||
@ -442,18 +442,18 @@ g_get_any_init (void)
|
|||||||
{
|
{
|
||||||
struct passwd *pw = NULL;
|
struct passwd *pw = NULL;
|
||||||
gpointer buffer = NULL;
|
gpointer buffer = NULL;
|
||||||
|
|
||||||
# ifdef HAVE_GETPWUID_R
|
# ifdef HAVE_GETPWUID_R
|
||||||
struct passwd pwd;
|
struct passwd pwd;
|
||||||
guint bufsize = 64;
|
guint bufsize = 64;
|
||||||
gint error;
|
gint error;
|
||||||
|
|
||||||
while (1)
|
do
|
||||||
{
|
{
|
||||||
g_free (buffer);
|
g_free (buffer);
|
||||||
buffer = g_malloc (bufsize);
|
buffer = g_malloc (bufsize);
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
# ifdef HAVE_GETPWUID_R_POSIX
|
# ifdef HAVE_GETPWUID_R_POSIX
|
||||||
error = getpwuid_r (getuid (), &pwd, buffer, bufsize, &pw);
|
error = getpwuid_r (getuid (), &pwd, buffer, bufsize, &pw);
|
||||||
error = error < 0 ? errno : error;
|
error = error < 0 ? errno : error;
|
||||||
@ -461,33 +461,33 @@ g_get_any_init (void)
|
|||||||
pw = getpwuid_r (getuid (), &pwd, buffer, bufsize);
|
pw = getpwuid_r (getuid (), &pwd, buffer, bufsize);
|
||||||
error = pw ? 0 : errno;
|
error = pw ? 0 : errno;
|
||||||
# endif /* !HAVE_GETPWUID_R_POSIX */
|
# endif /* !HAVE_GETPWUID_R_POSIX */
|
||||||
|
|
||||||
/* Now there are actually only 3 cases to leave the loop:
|
if (!pw)
|
||||||
1. pw != NULL -> all went fine.
|
|
||||||
2. pw == NULL && ( error == 0 || error == ENOENT )
|
|
||||||
-> no such user (unlikely in the case of getuid ())
|
|
||||||
3. bufsize > 32k -> the problem can't be of ERANGE type */
|
|
||||||
if (pw)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (pw == NULL && ( error == 0 || error == ENOENT))
|
|
||||||
{
|
{
|
||||||
g_warning ("getpwuid_r(): failed due to: No such user %d.",
|
/* we bail out prematurely if the user id can't be found
|
||||||
getuid ());
|
* (should be pretty rare case actually), or if the buffer
|
||||||
break;
|
* should be sufficiently big and lookups are still not
|
||||||
|
* successfull.
|
||||||
|
*/
|
||||||
|
if (error == 0 || error == ENOENT)
|
||||||
|
{
|
||||||
|
g_warning ("getpwuid_r(): failed due to: No such user %d.",
|
||||||
|
getuid ());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (bufsize > 32 * 1024)
|
||||||
|
{
|
||||||
|
g_warning ("getpwuid_r(): failed due to: %s.",
|
||||||
|
g_strerror (error));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
bufsize *= 2;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (bufsize > 32 * 1024)
|
while (!pw);
|
||||||
{
|
|
||||||
g_warning ("getpwuid_r(): failed due to: %s.",
|
|
||||||
g_strerror (error));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
bufsize *= 2;
|
|
||||||
}
|
|
||||||
# endif /* !HAVE_GETPWUID_R */
|
# endif /* !HAVE_GETPWUID_R */
|
||||||
|
|
||||||
if (!pw)
|
if (!pw)
|
||||||
{
|
{
|
||||||
setpwent ();
|
setpwent ();
|
||||||
@ -503,9 +503,9 @@ g_get_any_init (void)
|
|||||||
}
|
}
|
||||||
g_free (buffer);
|
g_free (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* !HAVE_PWD_H */
|
#else /* !HAVE_PWD_H */
|
||||||
|
|
||||||
# ifdef NATIVE_WIN32
|
# ifdef NATIVE_WIN32
|
||||||
{
|
{
|
||||||
guint len = 17;
|
guint len = 17;
|
||||||
@ -518,14 +518,28 @@ g_get_any_init (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
# endif /* NATIVE_WIN32 */
|
# endif /* NATIVE_WIN32 */
|
||||||
|
|
||||||
#endif /* !HAVE_PWD_H */
|
#endif /* !HAVE_PWD_H */
|
||||||
|
|
||||||
if (!g_user_name)
|
if (!g_user_name)
|
||||||
g_user_name = g_strdup ("somebody");
|
g_user_name = g_strdup ("somebody");
|
||||||
if (!g_real_name)
|
if (!g_real_name)
|
||||||
g_real_name = g_strdup ("Unknown");
|
g_real_name = g_strdup ("Unknown");
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
gchar *p;
|
||||||
|
|
||||||
|
for (p = g_real_name; *p; p++)
|
||||||
|
if (*p == ',')
|
||||||
|
{
|
||||||
|
*p = 0;
|
||||||
|
p = g_strdup (g_real_name);
|
||||||
|
g_free (g_real_name);
|
||||||
|
g_real_name = p;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar*
|
gchar*
|
||||||
@ -621,7 +635,7 @@ gint
|
|||||||
g_direct_equal (gconstpointer v1,
|
g_direct_equal (gconstpointer v1,
|
||||||
gconstpointer v2)
|
gconstpointer v2)
|
||||||
{
|
{
|
||||||
return GPOINTER_TO_UINT (v1) == GPOINTER_TO_UINT (v2);
|
return v1 == v2;
|
||||||
}
|
}
|
||||||
|
|
||||||
gint
|
gint
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
Wed Feb 10 07:56:33 1999 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gmodule.c (g_module_error): fixed errernerous code wrt to thread
|
||||||
|
specific error string allocation handling.
|
||||||
|
|
||||||
Thu Jan 21 12:40:11 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
Thu Jan 21 12:40:11 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
* gmodule-dl.c (_g_module_build_path):
|
* gmodule-dl.c (_g_module_build_path):
|
||||||
|
@ -114,15 +114,8 @@ g_module_find_by_name (const gchar *name)
|
|||||||
static inline void
|
static inline void
|
||||||
g_module_set_error (const gchar *error)
|
g_module_set_error (const gchar *error)
|
||||||
{
|
{
|
||||||
gchar* module_error = g_static_private_get (&module_error_private);
|
g_static_private_set (&module_error_private, g_strdup (error), g_free);
|
||||||
if (module_error)
|
|
||||||
g_free (module_error);
|
|
||||||
if (error)
|
|
||||||
module_error = g_strdup (error);
|
|
||||||
else
|
|
||||||
module_error = NULL;
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
g_static_private_set (&module_error_private, module_error, g_free);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -246,8 +239,7 @@ g_module_open (const gchar *file_name,
|
|||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
|
||||||
saved_error = g_module_error();
|
saved_error = g_strdup (g_module_error ());
|
||||||
g_static_private_set (&module_error_private, NULL, NULL);
|
|
||||||
g_module_set_error (NULL);
|
g_module_set_error (NULL);
|
||||||
|
|
||||||
module = g_new (GModule, 1);
|
module = g_new (GModule, 1);
|
||||||
@ -281,6 +273,7 @@ g_module_open (const gchar *file_name,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
g_module_set_error (saved_error);
|
g_module_set_error (saved_error);
|
||||||
|
|
||||||
g_free (saved_error);
|
g_free (saved_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
35
gmutex.c
35
gmutex.c
@ -29,7 +29,8 @@
|
|||||||
|
|
||||||
typedef struct _GStaticPrivateNode GStaticPrivateNode;
|
typedef struct _GStaticPrivateNode GStaticPrivateNode;
|
||||||
|
|
||||||
struct _GStaticPrivateNode {
|
struct _GStaticPrivateNode
|
||||||
|
{
|
||||||
gpointer data;
|
gpointer data;
|
||||||
GDestroyNotify destroy;
|
GDestroyNotify destroy;
|
||||||
};
|
};
|
||||||
@ -72,12 +73,15 @@ void
|
|||||||
g_mutex_init (void)
|
g_mutex_init (void)
|
||||||
{
|
{
|
||||||
/* We let the main thread (the one that calls g_thread_init) inherit
|
/* We let the main thread (the one that calls g_thread_init) inherit
|
||||||
the data, that it set before calling g_thread_init */
|
* the data, that it set before calling g_thread_init
|
||||||
|
*/
|
||||||
gpointer private_old = g_thread_specific_private;
|
gpointer private_old = g_thread_specific_private;
|
||||||
|
|
||||||
g_thread_specific_private = g_private_new (g_static_private_free_data);
|
g_thread_specific_private = g_private_new (g_static_private_free_data);
|
||||||
|
|
||||||
/* we can not use g_private_set here, as g_threads_got_initialized is not
|
/* we can not use g_private_set here, as g_threads_got_initialized is not
|
||||||
yet set TRUE, whereas the private_set function is already set. */
|
* yet set TRUE, whereas the private_set function is already set.
|
||||||
|
*/
|
||||||
g_thread_functions_for_glib_use.private_set (g_thread_specific_private,
|
g_thread_functions_for_glib_use.private_set (g_thread_specific_private,
|
||||||
private_old);
|
private_old);
|
||||||
|
|
||||||
@ -115,7 +119,7 @@ g_static_private_get (GStaticPrivate *private_key)
|
|||||||
if (!private_key->index)
|
if (!private_key->index)
|
||||||
return NULL;
|
return NULL;
|
||||||
else if (private_key->index <= array->len)
|
else if (private_key->index <= array->len)
|
||||||
return g_array_index (array, GStaticPrivateNode, (private_key->index - 1)).data;
|
return g_array_index (array, GStaticPrivateNode, private_key->index - 1).data;
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -127,11 +131,12 @@ g_static_private_set (GStaticPrivate *private_key,
|
|||||||
{
|
{
|
||||||
GArray *array;
|
GArray *array;
|
||||||
static guint next_index = 0;
|
static guint next_index = 0;
|
||||||
|
GStaticPrivateNode *node;
|
||||||
|
|
||||||
array = g_private_get (g_thread_specific_private);
|
array = g_private_get (g_thread_specific_private);
|
||||||
if (!array)
|
if (!array)
|
||||||
{
|
{
|
||||||
array = g_array_new (FALSE, FALSE, sizeof(GStaticPrivateNode));
|
array = g_array_new (FALSE, TRUE, sizeof (GStaticPrivateNode));
|
||||||
g_private_set (g_thread_specific_private, array);
|
g_private_set (g_thread_specific_private, array);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,8 +153,22 @@ g_static_private_set (GStaticPrivate *private_key,
|
|||||||
if (private_key->index > array->len)
|
if (private_key->index > array->len)
|
||||||
g_array_set_size (array, private_key->index);
|
g_array_set_size (array, private_key->index);
|
||||||
|
|
||||||
g_array_index (array, GStaticPrivateNode, (private_key->index - 1)).data = data;
|
node = &g_array_index (array, GStaticPrivateNode, private_key->index - 1);
|
||||||
g_array_index (array, GStaticPrivateNode, (private_key->index - 1)).destroy = notify;
|
if (node->destroy)
|
||||||
|
{
|
||||||
|
gpointer ddata = node->data;
|
||||||
|
GDestroyNotify ddestroy = node->destroy;
|
||||||
|
|
||||||
|
node->data = data;
|
||||||
|
node->destroy = notify;
|
||||||
|
|
||||||
|
ddestroy (ddata);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
node->data = data;
|
||||||
|
node->destroy = notify;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -163,7 +182,7 @@ g_static_private_free_data (gpointer data)
|
|||||||
for (i = 0; i < array->len; i++ )
|
for (i = 0; i < array->len; i++ )
|
||||||
{
|
{
|
||||||
GStaticPrivateNode *node = &g_array_index (array, GStaticPrivateNode, i);
|
GStaticPrivateNode *node = &g_array_index (array, GStaticPrivateNode, i);
|
||||||
if (node->data && node->destroy)
|
if (node->destroy)
|
||||||
node->destroy (node->data);
|
node->destroy (node->data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
gstrfuncs.c
10
gstrfuncs.c
@ -644,13 +644,14 @@ g_strerror (gint errnum)
|
|||||||
#endif /* NO_SYS_ERRLIST */
|
#endif /* NO_SYS_ERRLIST */
|
||||||
|
|
||||||
msg = g_static_private_get (&msg_private);
|
msg = g_static_private_get (&msg_private);
|
||||||
if( !msg )
|
if (!msg)
|
||||||
{
|
{
|
||||||
msg = g_new( gchar, 64 );
|
msg = g_new (gchar, 64);
|
||||||
g_static_private_set (&msg_private, msg, g_free);
|
g_static_private_set (&msg_private, msg, g_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf (msg, "unknown error (%d)", errnum);
|
sprintf (msg, "unknown error (%d)", errnum);
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -770,13 +771,14 @@ g_strsignal (gint signum)
|
|||||||
#endif /* NO_SYS_SIGLIST */
|
#endif /* NO_SYS_SIGLIST */
|
||||||
|
|
||||||
msg = g_static_private_get (&msg_private);
|
msg = g_static_private_get (&msg_private);
|
||||||
if( !msg )
|
if (!msg)
|
||||||
{
|
{
|
||||||
msg = g_new( gchar, 64 );
|
msg = g_new (gchar, 64);
|
||||||
g_static_private_set (&msg_private, msg, g_free);
|
g_static_private_set (&msg_private, msg, g_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf (msg, "unknown signal (%d)", signum);
|
sprintf (msg, "unknown signal (%d)", signum);
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
84
gutils.c
84
gutils.c
@ -401,7 +401,7 @@ g_get_any_init (void)
|
|||||||
g_tmp_dir[k-1] = '\0';
|
g_tmp_dir[k-1] = '\0';
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!g_tmp_dir)
|
if (!g_tmp_dir)
|
||||||
{
|
{
|
||||||
#ifndef NATIVE_WIN32
|
#ifndef NATIVE_WIN32
|
||||||
@ -442,18 +442,18 @@ g_get_any_init (void)
|
|||||||
{
|
{
|
||||||
struct passwd *pw = NULL;
|
struct passwd *pw = NULL;
|
||||||
gpointer buffer = NULL;
|
gpointer buffer = NULL;
|
||||||
|
|
||||||
# ifdef HAVE_GETPWUID_R
|
# ifdef HAVE_GETPWUID_R
|
||||||
struct passwd pwd;
|
struct passwd pwd;
|
||||||
guint bufsize = 64;
|
guint bufsize = 64;
|
||||||
gint error;
|
gint error;
|
||||||
|
|
||||||
while (1)
|
do
|
||||||
{
|
{
|
||||||
g_free (buffer);
|
g_free (buffer);
|
||||||
buffer = g_malloc (bufsize);
|
buffer = g_malloc (bufsize);
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
# ifdef HAVE_GETPWUID_R_POSIX
|
# ifdef HAVE_GETPWUID_R_POSIX
|
||||||
error = getpwuid_r (getuid (), &pwd, buffer, bufsize, &pw);
|
error = getpwuid_r (getuid (), &pwd, buffer, bufsize, &pw);
|
||||||
error = error < 0 ? errno : error;
|
error = error < 0 ? errno : error;
|
||||||
@ -461,33 +461,33 @@ g_get_any_init (void)
|
|||||||
pw = getpwuid_r (getuid (), &pwd, buffer, bufsize);
|
pw = getpwuid_r (getuid (), &pwd, buffer, bufsize);
|
||||||
error = pw ? 0 : errno;
|
error = pw ? 0 : errno;
|
||||||
# endif /* !HAVE_GETPWUID_R_POSIX */
|
# endif /* !HAVE_GETPWUID_R_POSIX */
|
||||||
|
|
||||||
/* Now there are actually only 3 cases to leave the loop:
|
if (!pw)
|
||||||
1. pw != NULL -> all went fine.
|
|
||||||
2. pw == NULL && ( error == 0 || error == ENOENT )
|
|
||||||
-> no such user (unlikely in the case of getuid ())
|
|
||||||
3. bufsize > 32k -> the problem can't be of ERANGE type */
|
|
||||||
if (pw)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (pw == NULL && ( error == 0 || error == ENOENT))
|
|
||||||
{
|
{
|
||||||
g_warning ("getpwuid_r(): failed due to: No such user %d.",
|
/* we bail out prematurely if the user id can't be found
|
||||||
getuid ());
|
* (should be pretty rare case actually), or if the buffer
|
||||||
break;
|
* should be sufficiently big and lookups are still not
|
||||||
|
* successfull.
|
||||||
|
*/
|
||||||
|
if (error == 0 || error == ENOENT)
|
||||||
|
{
|
||||||
|
g_warning ("getpwuid_r(): failed due to: No such user %d.",
|
||||||
|
getuid ());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (bufsize > 32 * 1024)
|
||||||
|
{
|
||||||
|
g_warning ("getpwuid_r(): failed due to: %s.",
|
||||||
|
g_strerror (error));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
bufsize *= 2;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (bufsize > 32 * 1024)
|
while (!pw);
|
||||||
{
|
|
||||||
g_warning ("getpwuid_r(): failed due to: %s.",
|
|
||||||
g_strerror (error));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
bufsize *= 2;
|
|
||||||
}
|
|
||||||
# endif /* !HAVE_GETPWUID_R */
|
# endif /* !HAVE_GETPWUID_R */
|
||||||
|
|
||||||
if (!pw)
|
if (!pw)
|
||||||
{
|
{
|
||||||
setpwent ();
|
setpwent ();
|
||||||
@ -503,9 +503,9 @@ g_get_any_init (void)
|
|||||||
}
|
}
|
||||||
g_free (buffer);
|
g_free (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* !HAVE_PWD_H */
|
#else /* !HAVE_PWD_H */
|
||||||
|
|
||||||
# ifdef NATIVE_WIN32
|
# ifdef NATIVE_WIN32
|
||||||
{
|
{
|
||||||
guint len = 17;
|
guint len = 17;
|
||||||
@ -518,14 +518,28 @@ g_get_any_init (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
# endif /* NATIVE_WIN32 */
|
# endif /* NATIVE_WIN32 */
|
||||||
|
|
||||||
#endif /* !HAVE_PWD_H */
|
#endif /* !HAVE_PWD_H */
|
||||||
|
|
||||||
if (!g_user_name)
|
if (!g_user_name)
|
||||||
g_user_name = g_strdup ("somebody");
|
g_user_name = g_strdup ("somebody");
|
||||||
if (!g_real_name)
|
if (!g_real_name)
|
||||||
g_real_name = g_strdup ("Unknown");
|
g_real_name = g_strdup ("Unknown");
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
gchar *p;
|
||||||
|
|
||||||
|
for (p = g_real_name; *p; p++)
|
||||||
|
if (*p == ',')
|
||||||
|
{
|
||||||
|
*p = 0;
|
||||||
|
p = g_strdup (g_real_name);
|
||||||
|
g_free (g_real_name);
|
||||||
|
g_real_name = p;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar*
|
gchar*
|
||||||
@ -621,7 +635,7 @@ gint
|
|||||||
g_direct_equal (gconstpointer v1,
|
g_direct_equal (gconstpointer v1,
|
||||||
gconstpointer v2)
|
gconstpointer v2)
|
||||||
{
|
{
|
||||||
return GPOINTER_TO_UINT (v1) == GPOINTER_TO_UINT (v2);
|
return v1 == v2;
|
||||||
}
|
}
|
||||||
|
|
||||||
gint
|
gint
|
||||||
|
Loading…
x
Reference in New Issue
Block a user