+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
. glist.c, gnode.c, gslist.c: allocate pools of 128 items instead
+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
. glist.c, gnode.c, gslist.c: allocate pools of 128 items instead
+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
. glist.c, gnode.c, gslist.c: allocate pools of 128 items instead
+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
. glist.c, gnode.c, gslist.c: allocate pools of 128 items instead
+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
. glist.c, gnode.c, gslist.c: allocate pools of 128 items instead
+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
. glist.c, gnode.c, gslist.c: allocate pools of 128 items instead
+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
. glist.c, gnode.c, gslist.c: allocate pools of 128 items instead
+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
. glist.c, gnode.c, gslist.c: allocate pools of 128 items instead
* 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_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_index(a,t,i) (((t*)a->data)[i])
+#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_insert_val(a,i,v) g_array_insert_vals (a, i, &v, 1)
+#define g_array_index(a,t,i) (((t*) (a)->data) [(i)])
GArray* g_array_new (gboolean zero_terminated,
gboolean clear,
/* This "hash" function will just return the key's adress as an
* unsigned integer. Useful for hashing on plain adresses or
* 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);
gint g_direct_equal (gconstpointer v,
* 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_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_index(a,t,i) (((t*)a->data)[i])
+#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_insert_val(a,i,v) g_array_insert_vals (a, i, &v, 1)
+#define g_array_index(a,t,i) (((t*) (a)->data) [(i)])
GArray* g_array_new (gboolean zero_terminated,
gboolean clear,
/* This "hash" function will just return the key's adress as an
* unsigned integer. Useful for hashing on plain adresses or
* 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);
gint g_direct_equal (gconstpointer v,
#endif /* NO_SYS_ERRLIST */
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);
}
sprintf (msg, "unknown error (%d)", errnum);
+
return msg;
}
#endif /* NO_SYS_SIGLIST */
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);
}
sprintf (msg, "unknown signal (%d)", signum);
+
return msg;
}
g_tmp_dir[k-1] = '\0';
}
#endif
-
+
if (!g_tmp_dir)
{
#ifndef NATIVE_WIN32
{
struct passwd *pw = NULL;
gpointer buffer = NULL;
-
+
# ifdef HAVE_GETPWUID_R
struct passwd pwd;
guint bufsize = 64;
gint error;
-
- while (1)
+
+ do
{
g_free (buffer);
buffer = g_malloc (bufsize);
errno = 0;
-
+
# ifdef HAVE_GETPWUID_R_POSIX
error = getpwuid_r (getuid (), &pwd, buffer, bufsize, &pw);
error = error < 0 ? errno : error;
pw = getpwuid_r (getuid (), &pwd, buffer, bufsize);
error = pw ? 0 : errno;
# endif /* !HAVE_GETPWUID_R_POSIX */
-
- /* Now there are actually only 3 cases to leave the loop:
- 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))
+
+ if (!pw)
{
- 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;
+ /* we bail out prematurely if the user id can't be found
+ * (should be pretty rare case actually), or if the buffer
+ * 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;
}
-
- bufsize *= 2;
- }
+ }
+ while (!pw);
# endif /* !HAVE_GETPWUID_R */
-
+
if (!pw)
{
setpwent ();
}
g_free (buffer);
}
-
+
#else /* !HAVE_PWD_H */
-
+
# ifdef NATIVE_WIN32
{
guint len = 17;
}
}
# endif /* NATIVE_WIN32 */
-
+
#endif /* !HAVE_PWD_H */
-
+
if (!g_user_name)
g_user_name = g_strdup ("somebody");
if (!g_real_name)
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*
g_direct_equal (gconstpointer v1,
gconstpointer v2)
{
- return GPOINTER_TO_UINT (v1) == GPOINTER_TO_UINT (v2);
+ return v1 == v2;
}
gint
+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>
* gmodule-dl.c (_g_module_build_path):
static inline void
g_module_set_error (const gchar *error)
{
- gchar* module_error = g_static_private_get (&module_error_private);
- if (module_error)
- g_free (module_error);
- if (error)
- module_error = g_strdup (error);
- else
- module_error = NULL;
+ g_static_private_set (&module_error_private, g_strdup (error), g_free);
errno = 0;
- g_static_private_set (&module_error_private, module_error, g_free);
}
return module;
}
- saved_error = g_module_error();
- g_static_private_set (&module_error_private, NULL, NULL);
+ saved_error = g_strdup (g_module_error ());
g_module_set_error (NULL);
module = g_new (GModule, 1);
}
else
g_module_set_error (saved_error);
+
g_free (saved_error);
}
typedef struct _GStaticPrivateNode GStaticPrivateNode;
-struct _GStaticPrivateNode {
+struct _GStaticPrivateNode
+{
gpointer data;
GDestroyNotify destroy;
};
g_mutex_init (void)
{
/* 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;
+
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
- 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,
private_old);
if (!private_key->index)
return NULL;
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
return NULL;
}
{
GArray *array;
static guint next_index = 0;
+ GStaticPrivateNode *node;
array = g_private_get (g_thread_specific_private);
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);
}
if (private_key->index > array->len)
g_array_set_size (array, private_key->index);
- g_array_index (array, GStaticPrivateNode, (private_key->index - 1)).data = data;
- g_array_index (array, GStaticPrivateNode, (private_key->index - 1)).destroy = notify;
+ node = &g_array_index (array, GStaticPrivateNode, private_key->index - 1);
+ 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
for (i = 0; i < array->len; i++ )
{
GStaticPrivateNode *node = &g_array_index (array, GStaticPrivateNode, i);
- if (node->data && node->destroy)
+ if (node->destroy)
node->destroy (node->data);
}
}
#endif /* NO_SYS_ERRLIST */
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);
}
sprintf (msg, "unknown error (%d)", errnum);
+
return msg;
}
#endif /* NO_SYS_SIGLIST */
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);
}
sprintf (msg, "unknown signal (%d)", signum);
+
return msg;
}
g_tmp_dir[k-1] = '\0';
}
#endif
-
+
if (!g_tmp_dir)
{
#ifndef NATIVE_WIN32
{
struct passwd *pw = NULL;
gpointer buffer = NULL;
-
+
# ifdef HAVE_GETPWUID_R
struct passwd pwd;
guint bufsize = 64;
gint error;
-
- while (1)
+
+ do
{
g_free (buffer);
buffer = g_malloc (bufsize);
errno = 0;
-
+
# ifdef HAVE_GETPWUID_R_POSIX
error = getpwuid_r (getuid (), &pwd, buffer, bufsize, &pw);
error = error < 0 ? errno : error;
pw = getpwuid_r (getuid (), &pwd, buffer, bufsize);
error = pw ? 0 : errno;
# endif /* !HAVE_GETPWUID_R_POSIX */
-
- /* Now there are actually only 3 cases to leave the loop:
- 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))
+
+ if (!pw)
{
- 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;
+ /* we bail out prematurely if the user id can't be found
+ * (should be pretty rare case actually), or if the buffer
+ * 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;
}
-
- bufsize *= 2;
- }
+ }
+ while (!pw);
# endif /* !HAVE_GETPWUID_R */
-
+
if (!pw)
{
setpwent ();
}
g_free (buffer);
}
-
+
#else /* !HAVE_PWD_H */
-
+
# ifdef NATIVE_WIN32
{
guint len = 17;
}
}
# endif /* NATIVE_WIN32 */
-
+
#endif /* !HAVE_PWD_H */
-
+
if (!g_user_name)
g_user_name = g_strdup ("somebody");
if (!g_real_name)
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*
g_direct_equal (gconstpointer v1,
gconstpointer v2)
{
- return GPOINTER_TO_UINT (v1) == GPOINTER_TO_UINT (v2);
+ return v1 == v2;
}
gint