mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-11 15:06:14 +01:00
minor optimization.
Wed Mar 1 10:39:39 2000 Tim Janik <timj@gtk.org> * gslist.c (g_slist_reverse): minor optimization. * testglib.c (g_node_test): added a couple of tests for g_node_copy(). * glib.h: * gnode.c (g_node_copy): new function to copy subtrees, supplied by dbsears@ix.netcom.com. changed iterator to walk the children list backwards, so we get down from O(n^2) to O(n). * gnode.c (g_node_first_sibling): applied patch from dbsears@ix.netcom.com to optimize access if node->parent is present. * gutils.c (g_get_any_init): backed out HAVE_PW_GECOS check around assignment of g_real_name, sicne HAVE_PW_GECOS is never defined and thus breaks the original code. * merged changes from 1.2.7. Sat Feb 19 19:43:29 2000 Tim Janik <timj@gtk.org> * testgmodule.c (main): added test to check that not yet bound symbols in shared libraries of the main module are retrievable, from David Gero. Fri Jan 28 11:37:41 2000 Owen Taylor <otaylor@redhat.com> Bug #4156 - Changes vaguely modelled after Scott Gifford's patch * gtimer.c (g_timer_elapsed): Never report negative times - clip times to 0. * gmain.c (g_timeout_prepare): Guard against unexpected clock shifts by never setting a timeout of more than data->interval msecs.
This commit is contained in:
parent
d568a76ae4
commit
db8baf6978
34
ChangeLog
34
ChangeLog
@ -1,3 +1,37 @@
|
|||||||
|
Wed Mar 1 10:39:39 2000 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gslist.c (g_slist_reverse): minor optimization.
|
||||||
|
|
||||||
|
* testglib.c (g_node_test): added a couple of tests for
|
||||||
|
g_node_copy().
|
||||||
|
|
||||||
|
* glib.h:
|
||||||
|
* gnode.c (g_node_copy): new function to copy subtrees,
|
||||||
|
supplied by dbsears@ix.netcom.com.
|
||||||
|
changed iterator to walk the children list backwards, so
|
||||||
|
we get down from O(n^2) to O(n).
|
||||||
|
|
||||||
|
* gnode.c (g_node_first_sibling): applied patch from
|
||||||
|
dbsears@ix.netcom.com to optimize access if node->parent
|
||||||
|
is present.
|
||||||
|
|
||||||
|
* gutils.c (g_get_any_init): backed out HAVE_PW_GECOS check around
|
||||||
|
assignment of g_real_name, sicne HAVE_PW_GECOS is never defined and
|
||||||
|
thus breaks the original code.
|
||||||
|
|
||||||
|
* merged changes from 1.2.7.
|
||||||
|
|
||||||
|
Fri Jan 28 11:37:41 2000 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
Bug #4156 - Changes vaguely modelled after Scott Gifford's patch
|
||||||
|
|
||||||
|
* gtimer.c (g_timer_elapsed): Never report negative times -
|
||||||
|
clip times to 0.
|
||||||
|
|
||||||
|
* gmain.c (g_timeout_prepare): Guard against unexpected
|
||||||
|
clock shifts by never setting a timeout of more than
|
||||||
|
data->interval msecs.
|
||||||
|
|
||||||
2000-02-27 Tor Lillqvist <tml@iki.fi>
|
2000-02-27 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* glib.def: Add new functions.
|
* glib.def: Add new functions.
|
||||||
|
@ -1,3 +1,37 @@
|
|||||||
|
Wed Mar 1 10:39:39 2000 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gslist.c (g_slist_reverse): minor optimization.
|
||||||
|
|
||||||
|
* testglib.c (g_node_test): added a couple of tests for
|
||||||
|
g_node_copy().
|
||||||
|
|
||||||
|
* glib.h:
|
||||||
|
* gnode.c (g_node_copy): new function to copy subtrees,
|
||||||
|
supplied by dbsears@ix.netcom.com.
|
||||||
|
changed iterator to walk the children list backwards, so
|
||||||
|
we get down from O(n^2) to O(n).
|
||||||
|
|
||||||
|
* gnode.c (g_node_first_sibling): applied patch from
|
||||||
|
dbsears@ix.netcom.com to optimize access if node->parent
|
||||||
|
is present.
|
||||||
|
|
||||||
|
* gutils.c (g_get_any_init): backed out HAVE_PW_GECOS check around
|
||||||
|
assignment of g_real_name, sicne HAVE_PW_GECOS is never defined and
|
||||||
|
thus breaks the original code.
|
||||||
|
|
||||||
|
* merged changes from 1.2.7.
|
||||||
|
|
||||||
|
Fri Jan 28 11:37:41 2000 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
Bug #4156 - Changes vaguely modelled after Scott Gifford's patch
|
||||||
|
|
||||||
|
* gtimer.c (g_timer_elapsed): Never report negative times -
|
||||||
|
clip times to 0.
|
||||||
|
|
||||||
|
* gmain.c (g_timeout_prepare): Guard against unexpected
|
||||||
|
clock shifts by never setting a timeout of more than
|
||||||
|
data->interval msecs.
|
||||||
|
|
||||||
2000-02-27 Tor Lillqvist <tml@iki.fi>
|
2000-02-27 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* glib.def: Add new functions.
|
* glib.def: Add new functions.
|
||||||
|
@ -1,3 +1,37 @@
|
|||||||
|
Wed Mar 1 10:39:39 2000 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gslist.c (g_slist_reverse): minor optimization.
|
||||||
|
|
||||||
|
* testglib.c (g_node_test): added a couple of tests for
|
||||||
|
g_node_copy().
|
||||||
|
|
||||||
|
* glib.h:
|
||||||
|
* gnode.c (g_node_copy): new function to copy subtrees,
|
||||||
|
supplied by dbsears@ix.netcom.com.
|
||||||
|
changed iterator to walk the children list backwards, so
|
||||||
|
we get down from O(n^2) to O(n).
|
||||||
|
|
||||||
|
* gnode.c (g_node_first_sibling): applied patch from
|
||||||
|
dbsears@ix.netcom.com to optimize access if node->parent
|
||||||
|
is present.
|
||||||
|
|
||||||
|
* gutils.c (g_get_any_init): backed out HAVE_PW_GECOS check around
|
||||||
|
assignment of g_real_name, sicne HAVE_PW_GECOS is never defined and
|
||||||
|
thus breaks the original code.
|
||||||
|
|
||||||
|
* merged changes from 1.2.7.
|
||||||
|
|
||||||
|
Fri Jan 28 11:37:41 2000 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
Bug #4156 - Changes vaguely modelled after Scott Gifford's patch
|
||||||
|
|
||||||
|
* gtimer.c (g_timer_elapsed): Never report negative times -
|
||||||
|
clip times to 0.
|
||||||
|
|
||||||
|
* gmain.c (g_timeout_prepare): Guard against unexpected
|
||||||
|
clock shifts by never setting a timeout of more than
|
||||||
|
data->interval msecs.
|
||||||
|
|
||||||
2000-02-27 Tor Lillqvist <tml@iki.fi>
|
2000-02-27 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* glib.def: Add new functions.
|
* glib.def: Add new functions.
|
||||||
|
@ -1,3 +1,37 @@
|
|||||||
|
Wed Mar 1 10:39:39 2000 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gslist.c (g_slist_reverse): minor optimization.
|
||||||
|
|
||||||
|
* testglib.c (g_node_test): added a couple of tests for
|
||||||
|
g_node_copy().
|
||||||
|
|
||||||
|
* glib.h:
|
||||||
|
* gnode.c (g_node_copy): new function to copy subtrees,
|
||||||
|
supplied by dbsears@ix.netcom.com.
|
||||||
|
changed iterator to walk the children list backwards, so
|
||||||
|
we get down from O(n^2) to O(n).
|
||||||
|
|
||||||
|
* gnode.c (g_node_first_sibling): applied patch from
|
||||||
|
dbsears@ix.netcom.com to optimize access if node->parent
|
||||||
|
is present.
|
||||||
|
|
||||||
|
* gutils.c (g_get_any_init): backed out HAVE_PW_GECOS check around
|
||||||
|
assignment of g_real_name, sicne HAVE_PW_GECOS is never defined and
|
||||||
|
thus breaks the original code.
|
||||||
|
|
||||||
|
* merged changes from 1.2.7.
|
||||||
|
|
||||||
|
Fri Jan 28 11:37:41 2000 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
Bug #4156 - Changes vaguely modelled after Scott Gifford's patch
|
||||||
|
|
||||||
|
* gtimer.c (g_timer_elapsed): Never report negative times -
|
||||||
|
clip times to 0.
|
||||||
|
|
||||||
|
* gmain.c (g_timeout_prepare): Guard against unexpected
|
||||||
|
clock shifts by never setting a timeout of more than
|
||||||
|
data->interval msecs.
|
||||||
|
|
||||||
2000-02-27 Tor Lillqvist <tml@iki.fi>
|
2000-02-27 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* glib.def: Add new functions.
|
* glib.def: Add new functions.
|
||||||
|
@ -1,3 +1,37 @@
|
|||||||
|
Wed Mar 1 10:39:39 2000 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gslist.c (g_slist_reverse): minor optimization.
|
||||||
|
|
||||||
|
* testglib.c (g_node_test): added a couple of tests for
|
||||||
|
g_node_copy().
|
||||||
|
|
||||||
|
* glib.h:
|
||||||
|
* gnode.c (g_node_copy): new function to copy subtrees,
|
||||||
|
supplied by dbsears@ix.netcom.com.
|
||||||
|
changed iterator to walk the children list backwards, so
|
||||||
|
we get down from O(n^2) to O(n).
|
||||||
|
|
||||||
|
* gnode.c (g_node_first_sibling): applied patch from
|
||||||
|
dbsears@ix.netcom.com to optimize access if node->parent
|
||||||
|
is present.
|
||||||
|
|
||||||
|
* gutils.c (g_get_any_init): backed out HAVE_PW_GECOS check around
|
||||||
|
assignment of g_real_name, sicne HAVE_PW_GECOS is never defined and
|
||||||
|
thus breaks the original code.
|
||||||
|
|
||||||
|
* merged changes from 1.2.7.
|
||||||
|
|
||||||
|
Fri Jan 28 11:37:41 2000 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
Bug #4156 - Changes vaguely modelled after Scott Gifford's patch
|
||||||
|
|
||||||
|
* gtimer.c (g_timer_elapsed): Never report negative times -
|
||||||
|
clip times to 0.
|
||||||
|
|
||||||
|
* gmain.c (g_timeout_prepare): Guard against unexpected
|
||||||
|
clock shifts by never setting a timeout of more than
|
||||||
|
data->interval msecs.
|
||||||
|
|
||||||
2000-02-27 Tor Lillqvist <tml@iki.fi>
|
2000-02-27 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* glib.def: Add new functions.
|
* glib.def: Add new functions.
|
||||||
|
@ -1,3 +1,37 @@
|
|||||||
|
Wed Mar 1 10:39:39 2000 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gslist.c (g_slist_reverse): minor optimization.
|
||||||
|
|
||||||
|
* testglib.c (g_node_test): added a couple of tests for
|
||||||
|
g_node_copy().
|
||||||
|
|
||||||
|
* glib.h:
|
||||||
|
* gnode.c (g_node_copy): new function to copy subtrees,
|
||||||
|
supplied by dbsears@ix.netcom.com.
|
||||||
|
changed iterator to walk the children list backwards, so
|
||||||
|
we get down from O(n^2) to O(n).
|
||||||
|
|
||||||
|
* gnode.c (g_node_first_sibling): applied patch from
|
||||||
|
dbsears@ix.netcom.com to optimize access if node->parent
|
||||||
|
is present.
|
||||||
|
|
||||||
|
* gutils.c (g_get_any_init): backed out HAVE_PW_GECOS check around
|
||||||
|
assignment of g_real_name, sicne HAVE_PW_GECOS is never defined and
|
||||||
|
thus breaks the original code.
|
||||||
|
|
||||||
|
* merged changes from 1.2.7.
|
||||||
|
|
||||||
|
Fri Jan 28 11:37:41 2000 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
Bug #4156 - Changes vaguely modelled after Scott Gifford's patch
|
||||||
|
|
||||||
|
* gtimer.c (g_timer_elapsed): Never report negative times -
|
||||||
|
clip times to 0.
|
||||||
|
|
||||||
|
* gmain.c (g_timeout_prepare): Guard against unexpected
|
||||||
|
clock shifts by never setting a timeout of more than
|
||||||
|
data->interval msecs.
|
||||||
|
|
||||||
2000-02-27 Tor Lillqvist <tml@iki.fi>
|
2000-02-27 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* glib.def: Add new functions.
|
* glib.def: Add new functions.
|
||||||
|
@ -1,3 +1,37 @@
|
|||||||
|
Wed Mar 1 10:39:39 2000 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gslist.c (g_slist_reverse): minor optimization.
|
||||||
|
|
||||||
|
* testglib.c (g_node_test): added a couple of tests for
|
||||||
|
g_node_copy().
|
||||||
|
|
||||||
|
* glib.h:
|
||||||
|
* gnode.c (g_node_copy): new function to copy subtrees,
|
||||||
|
supplied by dbsears@ix.netcom.com.
|
||||||
|
changed iterator to walk the children list backwards, so
|
||||||
|
we get down from O(n^2) to O(n).
|
||||||
|
|
||||||
|
* gnode.c (g_node_first_sibling): applied patch from
|
||||||
|
dbsears@ix.netcom.com to optimize access if node->parent
|
||||||
|
is present.
|
||||||
|
|
||||||
|
* gutils.c (g_get_any_init): backed out HAVE_PW_GECOS check around
|
||||||
|
assignment of g_real_name, sicne HAVE_PW_GECOS is never defined and
|
||||||
|
thus breaks the original code.
|
||||||
|
|
||||||
|
* merged changes from 1.2.7.
|
||||||
|
|
||||||
|
Fri Jan 28 11:37:41 2000 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
Bug #4156 - Changes vaguely modelled after Scott Gifford's patch
|
||||||
|
|
||||||
|
* gtimer.c (g_timer_elapsed): Never report negative times -
|
||||||
|
clip times to 0.
|
||||||
|
|
||||||
|
* gmain.c (g_timeout_prepare): Guard against unexpected
|
||||||
|
clock shifts by never setting a timeout of more than
|
||||||
|
data->interval msecs.
|
||||||
|
|
||||||
2000-02-27 Tor Lillqvist <tml@iki.fi>
|
2000-02-27 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* glib.def: Add new functions.
|
* glib.def: Add new functions.
|
||||||
|
@ -1,3 +1,37 @@
|
|||||||
|
Wed Mar 1 10:39:39 2000 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gslist.c (g_slist_reverse): minor optimization.
|
||||||
|
|
||||||
|
* testglib.c (g_node_test): added a couple of tests for
|
||||||
|
g_node_copy().
|
||||||
|
|
||||||
|
* glib.h:
|
||||||
|
* gnode.c (g_node_copy): new function to copy subtrees,
|
||||||
|
supplied by dbsears@ix.netcom.com.
|
||||||
|
changed iterator to walk the children list backwards, so
|
||||||
|
we get down from O(n^2) to O(n).
|
||||||
|
|
||||||
|
* gnode.c (g_node_first_sibling): applied patch from
|
||||||
|
dbsears@ix.netcom.com to optimize access if node->parent
|
||||||
|
is present.
|
||||||
|
|
||||||
|
* gutils.c (g_get_any_init): backed out HAVE_PW_GECOS check around
|
||||||
|
assignment of g_real_name, sicne HAVE_PW_GECOS is never defined and
|
||||||
|
thus breaks the original code.
|
||||||
|
|
||||||
|
* merged changes from 1.2.7.
|
||||||
|
|
||||||
|
Fri Jan 28 11:37:41 2000 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
Bug #4156 - Changes vaguely modelled after Scott Gifford's patch
|
||||||
|
|
||||||
|
* gtimer.c (g_timer_elapsed): Never report negative times -
|
||||||
|
clip times to 0.
|
||||||
|
|
||||||
|
* gmain.c (g_timeout_prepare): Guard against unexpected
|
||||||
|
clock shifts by never setting a timeout of more than
|
||||||
|
data->interval msecs.
|
||||||
|
|
||||||
2000-02-27 Tor Lillqvist <tml@iki.fi>
|
2000-02-27 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* glib.def: Add new functions.
|
* glib.def: Add new functions.
|
||||||
|
23
glib.h
23
glib.h
@ -1159,6 +1159,7 @@ void g_node_pop_allocator (void);
|
|||||||
GNode* g_node_new (gpointer data);
|
GNode* g_node_new (gpointer data);
|
||||||
void g_node_destroy (GNode *root);
|
void g_node_destroy (GNode *root);
|
||||||
void g_node_unlink (GNode *node);
|
void g_node_unlink (GNode *node);
|
||||||
|
GNode* g_node_copy (GNode *node);
|
||||||
GNode* g_node_insert (GNode *parent,
|
GNode* g_node_insert (GNode *parent,
|
||||||
gint position,
|
gint position,
|
||||||
GNode *node);
|
GNode *node);
|
||||||
@ -1598,24 +1599,22 @@ gchar* g_strjoin (const gchar *separator,
|
|||||||
*/
|
*/
|
||||||
gchar* g_strcompress (const gchar *source);
|
gchar* g_strcompress (const gchar *source);
|
||||||
|
|
||||||
/* Copy a string escaping nonprintable characters like in C strings.
|
/* Convert between the operating system (or C runtime)
|
||||||
* Inverse of g_strcompress. The exceptions parameter, if non-NULL, points
|
|
||||||
* to a string containing characters that are not to be escaped.
|
|
||||||
*/
|
|
||||||
gchar* g_strescape (const gchar *source,
|
|
||||||
const gchar *exceptions);
|
|
||||||
/*
|
|
||||||
* Convert between the operating system (or C runtime)
|
|
||||||
* representation of file names and UTF-8.
|
* representation of file names and UTF-8.
|
||||||
*/
|
*/
|
||||||
gchar* g_filename_to_utf8 (const gchar *opsysstring);
|
gchar* g_filename_to_utf8 (const gchar *opsysstring);
|
||||||
gchar* g_filename_from_utf8 (const gchar *utf8string);
|
gchar* g_filename_from_utf8 (const gchar *utf8string);
|
||||||
|
|
||||||
/* Deprecated API:
|
/* Copy a string escaping nonprintable characters like in C strings.
|
||||||
* gchar* g_strescape (const gchar *source);
|
* Inverse of g_strcompress. The exceptions parameter, if non-NULL, points
|
||||||
* Luckily this function wasn't much used.
|
* to a string containing characters that are not to be escaped.
|
||||||
* Add a second NULL parameter in calls for mostly identical semantics.
|
*
|
||||||
|
* Deprecated API: gchar* g_strescape (const gchar *source);
|
||||||
|
* Luckily this function wasn't used much, using NULL as second parameter
|
||||||
|
* provides mostly identical semantics.
|
||||||
*/
|
*/
|
||||||
|
gchar* g_strescape (const gchar *source,
|
||||||
|
const gchar *exceptions);
|
||||||
|
|
||||||
gpointer g_memdup (gconstpointer mem,
|
gpointer g_memdup (gconstpointer mem,
|
||||||
guint byte_size);
|
guint byte_size);
|
||||||
|
23
glib/glib.h
23
glib/glib.h
@ -1159,6 +1159,7 @@ void g_node_pop_allocator (void);
|
|||||||
GNode* g_node_new (gpointer data);
|
GNode* g_node_new (gpointer data);
|
||||||
void g_node_destroy (GNode *root);
|
void g_node_destroy (GNode *root);
|
||||||
void g_node_unlink (GNode *node);
|
void g_node_unlink (GNode *node);
|
||||||
|
GNode* g_node_copy (GNode *node);
|
||||||
GNode* g_node_insert (GNode *parent,
|
GNode* g_node_insert (GNode *parent,
|
||||||
gint position,
|
gint position,
|
||||||
GNode *node);
|
GNode *node);
|
||||||
@ -1598,24 +1599,22 @@ gchar* g_strjoin (const gchar *separator,
|
|||||||
*/
|
*/
|
||||||
gchar* g_strcompress (const gchar *source);
|
gchar* g_strcompress (const gchar *source);
|
||||||
|
|
||||||
/* Copy a string escaping nonprintable characters like in C strings.
|
/* Convert between the operating system (or C runtime)
|
||||||
* Inverse of g_strcompress. The exceptions parameter, if non-NULL, points
|
|
||||||
* to a string containing characters that are not to be escaped.
|
|
||||||
*/
|
|
||||||
gchar* g_strescape (const gchar *source,
|
|
||||||
const gchar *exceptions);
|
|
||||||
/*
|
|
||||||
* Convert between the operating system (or C runtime)
|
|
||||||
* representation of file names and UTF-8.
|
* representation of file names and UTF-8.
|
||||||
*/
|
*/
|
||||||
gchar* g_filename_to_utf8 (const gchar *opsysstring);
|
gchar* g_filename_to_utf8 (const gchar *opsysstring);
|
||||||
gchar* g_filename_from_utf8 (const gchar *utf8string);
|
gchar* g_filename_from_utf8 (const gchar *utf8string);
|
||||||
|
|
||||||
/* Deprecated API:
|
/* Copy a string escaping nonprintable characters like in C strings.
|
||||||
* gchar* g_strescape (const gchar *source);
|
* Inverse of g_strcompress. The exceptions parameter, if non-NULL, points
|
||||||
* Luckily this function wasn't much used.
|
* to a string containing characters that are not to be escaped.
|
||||||
* Add a second NULL parameter in calls for mostly identical semantics.
|
*
|
||||||
|
* Deprecated API: gchar* g_strescape (const gchar *source);
|
||||||
|
* Luckily this function wasn't used much, using NULL as second parameter
|
||||||
|
* provides mostly identical semantics.
|
||||||
*/
|
*/
|
||||||
|
gchar* g_strescape (const gchar *source,
|
||||||
|
const gchar *exceptions);
|
||||||
|
|
||||||
gpointer g_memdup (gconstpointer mem,
|
gpointer g_memdup (gconstpointer mem,
|
||||||
guint byte_size);
|
guint byte_size);
|
||||||
|
66
glib/gmain.c
66
glib/gmain.c
@ -1236,6 +1236,22 @@ g_main_wakeup (void)
|
|||||||
|
|
||||||
/* Timeouts */
|
/* Timeouts */
|
||||||
|
|
||||||
|
static void
|
||||||
|
g_timeout_set_expiration (GTimeoutData *data,
|
||||||
|
GTimeVal *current_time)
|
||||||
|
{
|
||||||
|
guint seconds = data->interval / 1000;
|
||||||
|
guint msecs = data->interval - seconds * 1000;
|
||||||
|
|
||||||
|
data->expiration.tv_sec = current_time->tv_sec + seconds;
|
||||||
|
data->expiration.tv_usec = current_time->tv_usec + msecs * 1000;
|
||||||
|
if (data->expiration.tv_usec >= 1000000)
|
||||||
|
{
|
||||||
|
data->expiration.tv_usec -= 1000000;
|
||||||
|
data->expiration.tv_sec++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
g_timeout_prepare (gpointer source_data,
|
g_timeout_prepare (gpointer source_data,
|
||||||
GTimeVal *current_time,
|
GTimeVal *current_time,
|
||||||
@ -1245,12 +1261,24 @@ g_timeout_prepare (gpointer source_data,
|
|||||||
glong msec;
|
glong msec;
|
||||||
GTimeoutData *data = source_data;
|
GTimeoutData *data = source_data;
|
||||||
|
|
||||||
msec = (data->expiration.tv_sec - current_time->tv_sec) * 1000 +
|
msec = ((data->expiration.tv_sec - current_time->tv_sec) * 1000 +
|
||||||
(data->expiration.tv_usec - current_time->tv_usec) / 1000;
|
(data->expiration.tv_usec - current_time->tv_usec) / 1000);
|
||||||
|
|
||||||
*timeout = (msec <= 0) ? 0 : msec;
|
if (msec < 0)
|
||||||
|
msec = 0;
|
||||||
|
else if (msec > data->interval)
|
||||||
|
{
|
||||||
|
/* The system time has been set backwards, so we
|
||||||
|
* reset the expiration time to now + data->interval;
|
||||||
|
* this at least avoids hanging for long periods of time.
|
||||||
|
*/
|
||||||
|
g_timeout_set_expiration (data, current_time);
|
||||||
|
msec = data->interval;
|
||||||
|
}
|
||||||
|
|
||||||
return (msec <= 0);
|
*timeout = msec;
|
||||||
|
|
||||||
|
return msec == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -1260,9 +1288,9 @@ g_timeout_check (gpointer source_data,
|
|||||||
{
|
{
|
||||||
GTimeoutData *data = source_data;
|
GTimeoutData *data = source_data;
|
||||||
|
|
||||||
return (data->expiration.tv_sec < current_time->tv_sec) ||
|
return ((data->expiration.tv_sec < current_time->tv_sec) ||
|
||||||
((data->expiration.tv_sec == current_time->tv_sec) &&
|
((data->expiration.tv_sec == current_time->tv_sec) &&
|
||||||
(data->expiration.tv_usec <= current_time->tv_usec));
|
(data->expiration.tv_usec <= current_time->tv_usec)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -1274,16 +1302,8 @@ g_timeout_dispatch (gpointer source_data,
|
|||||||
|
|
||||||
if (data->callback (user_data))
|
if (data->callback (user_data))
|
||||||
{
|
{
|
||||||
guint seconds = data->interval / 1000;
|
g_timeout_set_expiration (data, dispatch_time);
|
||||||
guint msecs = data->interval - seconds * 1000;
|
|
||||||
|
|
||||||
data->expiration.tv_sec = dispatch_time->tv_sec + seconds;
|
|
||||||
data->expiration.tv_usec = dispatch_time->tv_usec + msecs * 1000;
|
|
||||||
if (data->expiration.tv_usec >= 1000000)
|
|
||||||
{
|
|
||||||
data->expiration.tv_usec -= 1000000;
|
|
||||||
data->expiration.tv_sec++;
|
|
||||||
}
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1297,24 +1317,14 @@ g_timeout_add_full (gint priority,
|
|||||||
gpointer data,
|
gpointer data,
|
||||||
GDestroyNotify notify)
|
GDestroyNotify notify)
|
||||||
{
|
{
|
||||||
guint seconds;
|
|
||||||
guint msecs;
|
|
||||||
GTimeoutData *timeout_data = g_new (GTimeoutData, 1);
|
GTimeoutData *timeout_data = g_new (GTimeoutData, 1);
|
||||||
|
GTimeVal current_time;
|
||||||
|
|
||||||
timeout_data->interval = interval;
|
timeout_data->interval = interval;
|
||||||
timeout_data->callback = function;
|
timeout_data->callback = function;
|
||||||
g_get_current_time (&timeout_data->expiration);
|
g_get_current_time (¤t_time);
|
||||||
|
|
||||||
seconds = timeout_data->interval / 1000;
|
g_timeout_set_expiration (timeout_data, ¤t_time);
|
||||||
msecs = timeout_data->interval - seconds * 1000;
|
|
||||||
|
|
||||||
timeout_data->expiration.tv_sec += seconds;
|
|
||||||
timeout_data->expiration.tv_usec += msecs * 1000;
|
|
||||||
if (timeout_data->expiration.tv_usec >= 1000000)
|
|
||||||
{
|
|
||||||
timeout_data->expiration.tv_usec -= 1000000;
|
|
||||||
timeout_data->expiration.tv_sec++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return g_source_add (priority, FALSE, &timeout_funcs, timeout_data, data, notify);
|
return g_source_add (priority, FALSE, &timeout_funcs, timeout_data, data, notify);
|
||||||
}
|
}
|
||||||
|
21
glib/gnode.c
21
glib/gnode.c
@ -189,6 +189,24 @@ g_node_unlink (GNode *node)
|
|||||||
node->prev = NULL;
|
node->prev = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GNode*
|
||||||
|
g_node_copy (GNode *node)
|
||||||
|
{
|
||||||
|
GNode *new_node = NULL;
|
||||||
|
|
||||||
|
if (node)
|
||||||
|
{
|
||||||
|
GNode *child;
|
||||||
|
|
||||||
|
new_node = g_node_new (node->data);
|
||||||
|
|
||||||
|
for (child = g_node_last_child (node); child; child = child->prev)
|
||||||
|
g_node_prepend (new_node, g_node_copy (child));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new_node;
|
||||||
|
}
|
||||||
|
|
||||||
GNode*
|
GNode*
|
||||||
g_node_insert (GNode *parent,
|
g_node_insert (GNode *parent,
|
||||||
gint position,
|
gint position,
|
||||||
@ -917,6 +935,9 @@ g_node_first_sibling (GNode *node)
|
|||||||
{
|
{
|
||||||
g_return_val_if_fail (node != NULL, NULL);
|
g_return_val_if_fail (node != NULL, NULL);
|
||||||
|
|
||||||
|
if (node->parent)
|
||||||
|
return node->parent->children;
|
||||||
|
|
||||||
while (node->prev)
|
while (node->prev)
|
||||||
node = node->prev;
|
node = node->prev;
|
||||||
|
|
||||||
|
@ -377,32 +377,26 @@ g_slist_copy (GSList *list)
|
|||||||
GSList*
|
GSList*
|
||||||
g_slist_reverse (GSList *list)
|
g_slist_reverse (GSList *list)
|
||||||
{
|
{
|
||||||
GSList *tmp;
|
GSList *prev = NULL;
|
||||||
GSList *prev;
|
GSList *next = NULL;
|
||||||
GSList *last;
|
|
||||||
|
|
||||||
last = NULL;
|
|
||||||
prev = NULL;
|
|
||||||
|
|
||||||
while (list)
|
while (list)
|
||||||
{
|
{
|
||||||
last = list;
|
next = list->next;
|
||||||
|
|
||||||
tmp = list->next;
|
|
||||||
list->next = prev;
|
list->next = prev;
|
||||||
|
|
||||||
prev = list;
|
prev = list;
|
||||||
list = tmp;
|
list = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
return last;
|
return prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
GSList*
|
GSList*
|
||||||
g_slist_nth (GSList *list,
|
g_slist_nth (GSList *list,
|
||||||
guint n)
|
guint n)
|
||||||
{
|
{
|
||||||
while ((n-- > 0) && list)
|
while (n-- > 0 && list)
|
||||||
list = list->next;
|
list = list->next;
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
@ -412,7 +406,7 @@ gpointer
|
|||||||
g_slist_nth_data (GSList *list,
|
g_slist_nth_data (GSList *list,
|
||||||
guint n)
|
guint n)
|
||||||
{
|
{
|
||||||
while ((n-- > 0) && list)
|
while (n-- > 0 && list)
|
||||||
list = list->next;
|
list = list->next;
|
||||||
|
|
||||||
return list ? list->data : NULL;
|
return list ? list->data : NULL;
|
||||||
|
@ -1291,8 +1291,6 @@ g_filename_from_utf8 (const gchar *utf8string)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* blame Elliot for these next five routines */
|
|
||||||
gchar*
|
gchar*
|
||||||
g_strchug (gchar *string)
|
g_strchug (gchar *string)
|
||||||
{
|
{
|
||||||
|
@ -184,9 +184,16 @@ g_timer_elapsed (GTimer *timer,
|
|||||||
elapsed.tv_sec = rtimer->end.tv_sec - rtimer->start.tv_sec;
|
elapsed.tv_sec = rtimer->end.tv_sec - rtimer->start.tv_sec;
|
||||||
|
|
||||||
total = elapsed.tv_sec + ((gdouble) elapsed.tv_usec / 1e6);
|
total = elapsed.tv_sec + ((gdouble) elapsed.tv_usec / 1e6);
|
||||||
|
if (total < 0)
|
||||||
|
{
|
||||||
|
total = 0;
|
||||||
|
|
||||||
if (microseconds)
|
if (microseconds)
|
||||||
|
*microseconds = 0;
|
||||||
|
}
|
||||||
|
else if (microseconds)
|
||||||
*microseconds = elapsed.tv_usec;
|
*microseconds = elapsed.tv_usec;
|
||||||
|
|
||||||
#endif /* !G_OS_WIN32 */
|
#endif /* !G_OS_WIN32 */
|
||||||
|
|
||||||
return total;
|
return total;
|
||||||
|
@ -515,8 +515,8 @@ g_get_any_init (void)
|
|||||||
*/
|
*/
|
||||||
if (error == 0 || error == ENOENT)
|
if (error == 0 || error == ENOENT)
|
||||||
{
|
{
|
||||||
g_warning ("getpwuid_r(): failed due to: "
|
g_warning ("getpwuid_r(): failed due to unknown user id (%lu)",
|
||||||
"No such user: %lu.", (unsigned long)getuid ());
|
(gulong) getuid ());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (bufsize > 32 * 1024)
|
if (bufsize > 32 * 1024)
|
||||||
@ -541,11 +541,7 @@ g_get_any_init (void)
|
|||||||
if (pw)
|
if (pw)
|
||||||
{
|
{
|
||||||
g_user_name = g_strdup (pw->pw_name);
|
g_user_name = g_strdup (pw->pw_name);
|
||||||
#ifdef HAVE_PW_GECOS
|
|
||||||
g_real_name = g_strdup (pw->pw_gecos);
|
g_real_name = g_strdup (pw->pw_gecos);
|
||||||
#else
|
|
||||||
g_real_name = g_strdup (g_user_name);
|
|
||||||
#endif
|
|
||||||
if (!g_home_dir)
|
if (!g_home_dir)
|
||||||
g_home_dir = g_strdup (pw->pw_dir);
|
g_home_dir = g_strdup (pw->pw_dir);
|
||||||
}
|
}
|
||||||
|
66
gmain.c
66
gmain.c
@ -1236,6 +1236,22 @@ g_main_wakeup (void)
|
|||||||
|
|
||||||
/* Timeouts */
|
/* Timeouts */
|
||||||
|
|
||||||
|
static void
|
||||||
|
g_timeout_set_expiration (GTimeoutData *data,
|
||||||
|
GTimeVal *current_time)
|
||||||
|
{
|
||||||
|
guint seconds = data->interval / 1000;
|
||||||
|
guint msecs = data->interval - seconds * 1000;
|
||||||
|
|
||||||
|
data->expiration.tv_sec = current_time->tv_sec + seconds;
|
||||||
|
data->expiration.tv_usec = current_time->tv_usec + msecs * 1000;
|
||||||
|
if (data->expiration.tv_usec >= 1000000)
|
||||||
|
{
|
||||||
|
data->expiration.tv_usec -= 1000000;
|
||||||
|
data->expiration.tv_sec++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
g_timeout_prepare (gpointer source_data,
|
g_timeout_prepare (gpointer source_data,
|
||||||
GTimeVal *current_time,
|
GTimeVal *current_time,
|
||||||
@ -1245,12 +1261,24 @@ g_timeout_prepare (gpointer source_data,
|
|||||||
glong msec;
|
glong msec;
|
||||||
GTimeoutData *data = source_data;
|
GTimeoutData *data = source_data;
|
||||||
|
|
||||||
msec = (data->expiration.tv_sec - current_time->tv_sec) * 1000 +
|
msec = ((data->expiration.tv_sec - current_time->tv_sec) * 1000 +
|
||||||
(data->expiration.tv_usec - current_time->tv_usec) / 1000;
|
(data->expiration.tv_usec - current_time->tv_usec) / 1000);
|
||||||
|
|
||||||
*timeout = (msec <= 0) ? 0 : msec;
|
if (msec < 0)
|
||||||
|
msec = 0;
|
||||||
|
else if (msec > data->interval)
|
||||||
|
{
|
||||||
|
/* The system time has been set backwards, so we
|
||||||
|
* reset the expiration time to now + data->interval;
|
||||||
|
* this at least avoids hanging for long periods of time.
|
||||||
|
*/
|
||||||
|
g_timeout_set_expiration (data, current_time);
|
||||||
|
msec = data->interval;
|
||||||
|
}
|
||||||
|
|
||||||
return (msec <= 0);
|
*timeout = msec;
|
||||||
|
|
||||||
|
return msec == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -1260,9 +1288,9 @@ g_timeout_check (gpointer source_data,
|
|||||||
{
|
{
|
||||||
GTimeoutData *data = source_data;
|
GTimeoutData *data = source_data;
|
||||||
|
|
||||||
return (data->expiration.tv_sec < current_time->tv_sec) ||
|
return ((data->expiration.tv_sec < current_time->tv_sec) ||
|
||||||
((data->expiration.tv_sec == current_time->tv_sec) &&
|
((data->expiration.tv_sec == current_time->tv_sec) &&
|
||||||
(data->expiration.tv_usec <= current_time->tv_usec));
|
(data->expiration.tv_usec <= current_time->tv_usec)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -1274,16 +1302,8 @@ g_timeout_dispatch (gpointer source_data,
|
|||||||
|
|
||||||
if (data->callback (user_data))
|
if (data->callback (user_data))
|
||||||
{
|
{
|
||||||
guint seconds = data->interval / 1000;
|
g_timeout_set_expiration (data, dispatch_time);
|
||||||
guint msecs = data->interval - seconds * 1000;
|
|
||||||
|
|
||||||
data->expiration.tv_sec = dispatch_time->tv_sec + seconds;
|
|
||||||
data->expiration.tv_usec = dispatch_time->tv_usec + msecs * 1000;
|
|
||||||
if (data->expiration.tv_usec >= 1000000)
|
|
||||||
{
|
|
||||||
data->expiration.tv_usec -= 1000000;
|
|
||||||
data->expiration.tv_sec++;
|
|
||||||
}
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1297,24 +1317,14 @@ g_timeout_add_full (gint priority,
|
|||||||
gpointer data,
|
gpointer data,
|
||||||
GDestroyNotify notify)
|
GDestroyNotify notify)
|
||||||
{
|
{
|
||||||
guint seconds;
|
|
||||||
guint msecs;
|
|
||||||
GTimeoutData *timeout_data = g_new (GTimeoutData, 1);
|
GTimeoutData *timeout_data = g_new (GTimeoutData, 1);
|
||||||
|
GTimeVal current_time;
|
||||||
|
|
||||||
timeout_data->interval = interval;
|
timeout_data->interval = interval;
|
||||||
timeout_data->callback = function;
|
timeout_data->callback = function;
|
||||||
g_get_current_time (&timeout_data->expiration);
|
g_get_current_time (¤t_time);
|
||||||
|
|
||||||
seconds = timeout_data->interval / 1000;
|
g_timeout_set_expiration (timeout_data, ¤t_time);
|
||||||
msecs = timeout_data->interval - seconds * 1000;
|
|
||||||
|
|
||||||
timeout_data->expiration.tv_sec += seconds;
|
|
||||||
timeout_data->expiration.tv_usec += msecs * 1000;
|
|
||||||
if (timeout_data->expiration.tv_usec >= 1000000)
|
|
||||||
{
|
|
||||||
timeout_data->expiration.tv_usec -= 1000000;
|
|
||||||
timeout_data->expiration.tv_sec++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return g_source_add (priority, FALSE, &timeout_funcs, timeout_data, data, notify);
|
return g_source_add (priority, FALSE, &timeout_funcs, timeout_data, data, notify);
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,11 @@ Wed Mar 1 05:34:47 2000 Tim Janik <timj@gtk.org>
|
|||||||
|
|
||||||
* merges from glib-1-2.
|
* merges from glib-1-2.
|
||||||
|
|
||||||
|
Sat Feb 19 19:43:29 2000 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* testgmodule.c (main): added test to check that not yet bound symbols
|
||||||
|
in shared libraries of the main module are retrievable, from David Gero.
|
||||||
|
|
||||||
2000-01-13 Martin Baulig <martin@home-of-linux.org>
|
2000-01-13 Martin Baulig <martin@home-of-linux.org>
|
||||||
|
|
||||||
* gmodule.c (g_module_open): Check whether `check_init' is not NULL
|
* gmodule.c (g_module_open): Check whether `check_init' is not NULL
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#undef G_LOG_DOMAIN
|
#undef G_LOG_DOMAIN
|
||||||
#include <gmodule.h>
|
#include <gmodule.h>
|
||||||
|
#include "gmoduleconf.h"
|
||||||
|
|
||||||
|
|
||||||
G_MODULE_EXPORT void
|
G_MODULE_EXPORT void
|
||||||
@ -37,7 +38,7 @@ g_clash_func (void)
|
|||||||
typedef void (*SimpleFunc) (void);
|
typedef void (*SimpleFunc) (void);
|
||||||
typedef void (*GModuleFunc) (GModule *);
|
typedef void (*GModuleFunc) (GModule *);
|
||||||
|
|
||||||
SimpleFunc gplugin_clash_func;
|
static SimpleFunc plugin_clash_func = NULL;
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int arg,
|
main (int arg,
|
||||||
@ -55,7 +56,10 @@ main (int arg,
|
|||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
plugin_a = g_strconcat (string, "\\libgplugin_a.dll", NULL);
|
plugin_a = g_strconcat (string, "\\libgplugin_a.dll", NULL);
|
||||||
plugin_b = g_strconcat (string, "\\libgplugin_b.dll", NULL);
|
plugin_b = g_strconcat (string, "\\libgplugin_b.dll", NULL);
|
||||||
#else /* !G_OS_WIN32 */
|
#elif (G_MODULE_IMPL == G_MODULE_IMPL_DLD)
|
||||||
|
plugin_a = g_strconcat (string, "/.libs/", "libgplugin_a.sl", NULL);
|
||||||
|
plugin_b = g_strconcat (string, "/.libs/", "libgplugin_b.sl", NULL);
|
||||||
|
#else /* G_MODULE_IMPL != G_MODULE_IMPL_DLD && !G_OS_WIN32 */
|
||||||
plugin_a = g_strconcat (string, "/.libs/", "libgplugin_a.so", NULL);
|
plugin_a = g_strconcat (string, "/.libs/", "libgplugin_a.so", NULL);
|
||||||
plugin_b = g_strconcat (string, "/.libs/", "libgplugin_b.so", NULL);
|
plugin_b = g_strconcat (string, "/.libs/", "libgplugin_b.so", NULL);
|
||||||
#endif /* G_OS_WIN32 */
|
#endif /* G_OS_WIN32 */
|
||||||
@ -70,6 +74,15 @@ main (int arg,
|
|||||||
g_print ("error: %s\n", g_module_error ());
|
g_print ("error: %s\n", g_module_error ());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
g_print ("check that not yet bound symbols in shared libraries of main module are retrievable:\n");
|
||||||
|
string = "g_module_close";
|
||||||
|
g_print ("retrive symbol `%s' from \"%s\":\n", string, g_basename (g_module_name (module_self)));
|
||||||
|
if (!g_module_symbol (module_self, string, (gpointer) &f_self))
|
||||||
|
{
|
||||||
|
g_print ("error: %s\n", g_module_error ());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
g_print ("retrived symbol `%s' as %p\n", string, f_self);
|
||||||
g_print ("load plugin from \"%s\"\n", plugin_a);
|
g_print ("load plugin from \"%s\"\n", plugin_a);
|
||||||
module_a = g_module_open (plugin_a, G_MODULE_BIND_LAZY);
|
module_a = g_module_open (plugin_a, G_MODULE_BIND_LAZY);
|
||||||
if (!module_a)
|
if (!module_a)
|
||||||
@ -137,6 +150,10 @@ main (int arg,
|
|||||||
/* get and call clashing plugin functions
|
/* get and call clashing plugin functions
|
||||||
*/
|
*/
|
||||||
string = "gplugin_clash_func";
|
string = "gplugin_clash_func";
|
||||||
|
g_print ("retrive symbol `%s' from \"%s\"\n", string, g_basename (g_module_name (module_self)));
|
||||||
|
if (!g_module_symbol (module_self, string, (gpointer) &f_self))
|
||||||
|
f_self = NULL;
|
||||||
|
g_print ("retrived function `%s' from self: %p\n", string, f_self);
|
||||||
g_print ("retrive symbol `%s' from \"%s\"\n", string, g_basename (g_module_name (module_a)));
|
g_print ("retrive symbol `%s' from \"%s\"\n", string, g_basename (g_module_name (module_a)));
|
||||||
if (!g_module_symbol (module_a, string, (gpointer) &f_a))
|
if (!g_module_symbol (module_a, string, (gpointer) &f_a))
|
||||||
{
|
{
|
||||||
@ -150,11 +167,11 @@ main (int arg,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
g_print ("call plugin function(%p) A: ", f_a);
|
g_print ("call plugin function(%p) A: ", f_a);
|
||||||
gplugin_clash_func = f_a;
|
plugin_clash_func = f_a;
|
||||||
gplugin_clash_func ();
|
plugin_clash_func ();
|
||||||
g_print ("call plugin function(%p) B: ", f_b);
|
g_print ("call plugin function(%p) B: ", f_b);
|
||||||
gplugin_clash_func = f_b;
|
plugin_clash_func = f_b;
|
||||||
gplugin_clash_func ();
|
plugin_clash_func ();
|
||||||
|
|
||||||
/* call gmodule function form A
|
/* call gmodule function form A
|
||||||
*/
|
*/
|
||||||
|
21
gnode.c
21
gnode.c
@ -189,6 +189,24 @@ g_node_unlink (GNode *node)
|
|||||||
node->prev = NULL;
|
node->prev = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GNode*
|
||||||
|
g_node_copy (GNode *node)
|
||||||
|
{
|
||||||
|
GNode *new_node = NULL;
|
||||||
|
|
||||||
|
if (node)
|
||||||
|
{
|
||||||
|
GNode *child;
|
||||||
|
|
||||||
|
new_node = g_node_new (node->data);
|
||||||
|
|
||||||
|
for (child = g_node_last_child (node); child; child = child->prev)
|
||||||
|
g_node_prepend (new_node, g_node_copy (child));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new_node;
|
||||||
|
}
|
||||||
|
|
||||||
GNode*
|
GNode*
|
||||||
g_node_insert (GNode *parent,
|
g_node_insert (GNode *parent,
|
||||||
gint position,
|
gint position,
|
||||||
@ -917,6 +935,9 @@ g_node_first_sibling (GNode *node)
|
|||||||
{
|
{
|
||||||
g_return_val_if_fail (node != NULL, NULL);
|
g_return_val_if_fail (node != NULL, NULL);
|
||||||
|
|
||||||
|
if (node->parent)
|
||||||
|
return node->parent->children;
|
||||||
|
|
||||||
while (node->prev)
|
while (node->prev)
|
||||||
node = node->prev;
|
node = node->prev;
|
||||||
|
|
||||||
|
20
gslist.c
20
gslist.c
@ -377,32 +377,26 @@ g_slist_copy (GSList *list)
|
|||||||
GSList*
|
GSList*
|
||||||
g_slist_reverse (GSList *list)
|
g_slist_reverse (GSList *list)
|
||||||
{
|
{
|
||||||
GSList *tmp;
|
GSList *prev = NULL;
|
||||||
GSList *prev;
|
GSList *next = NULL;
|
||||||
GSList *last;
|
|
||||||
|
|
||||||
last = NULL;
|
|
||||||
prev = NULL;
|
|
||||||
|
|
||||||
while (list)
|
while (list)
|
||||||
{
|
{
|
||||||
last = list;
|
next = list->next;
|
||||||
|
|
||||||
tmp = list->next;
|
|
||||||
list->next = prev;
|
list->next = prev;
|
||||||
|
|
||||||
prev = list;
|
prev = list;
|
||||||
list = tmp;
|
list = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
return last;
|
return prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
GSList*
|
GSList*
|
||||||
g_slist_nth (GSList *list,
|
g_slist_nth (GSList *list,
|
||||||
guint n)
|
guint n)
|
||||||
{
|
{
|
||||||
while ((n-- > 0) && list)
|
while (n-- > 0 && list)
|
||||||
list = list->next;
|
list = list->next;
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
@ -412,7 +406,7 @@ gpointer
|
|||||||
g_slist_nth_data (GSList *list,
|
g_slist_nth_data (GSList *list,
|
||||||
guint n)
|
guint n)
|
||||||
{
|
{
|
||||||
while ((n-- > 0) && list)
|
while (n-- > 0 && list)
|
||||||
list = list->next;
|
list = list->next;
|
||||||
|
|
||||||
return list ? list->data : NULL;
|
return list ? list->data : NULL;
|
||||||
|
@ -1291,8 +1291,6 @@ g_filename_from_utf8 (const gchar *utf8string)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* blame Elliot for these next five routines */
|
|
||||||
gchar*
|
gchar*
|
||||||
g_strchug (gchar *string)
|
g_strchug (gchar *string)
|
||||||
{
|
{
|
||||||
|
7
gtimer.c
7
gtimer.c
@ -184,9 +184,16 @@ g_timer_elapsed (GTimer *timer,
|
|||||||
elapsed.tv_sec = rtimer->end.tv_sec - rtimer->start.tv_sec;
|
elapsed.tv_sec = rtimer->end.tv_sec - rtimer->start.tv_sec;
|
||||||
|
|
||||||
total = elapsed.tv_sec + ((gdouble) elapsed.tv_usec / 1e6);
|
total = elapsed.tv_sec + ((gdouble) elapsed.tv_usec / 1e6);
|
||||||
|
if (total < 0)
|
||||||
|
{
|
||||||
|
total = 0;
|
||||||
|
|
||||||
if (microseconds)
|
if (microseconds)
|
||||||
|
*microseconds = 0;
|
||||||
|
}
|
||||||
|
else if (microseconds)
|
||||||
*microseconds = elapsed.tv_usec;
|
*microseconds = elapsed.tv_usec;
|
||||||
|
|
||||||
#endif /* !G_OS_WIN32 */
|
#endif /* !G_OS_WIN32 */
|
||||||
|
|
||||||
return total;
|
return total;
|
||||||
|
8
gutils.c
8
gutils.c
@ -515,8 +515,8 @@ g_get_any_init (void)
|
|||||||
*/
|
*/
|
||||||
if (error == 0 || error == ENOENT)
|
if (error == 0 || error == ENOENT)
|
||||||
{
|
{
|
||||||
g_warning ("getpwuid_r(): failed due to: "
|
g_warning ("getpwuid_r(): failed due to unknown user id (%lu)",
|
||||||
"No such user: %lu.", (unsigned long)getuid ());
|
(gulong) getuid ());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (bufsize > 32 * 1024)
|
if (bufsize > 32 * 1024)
|
||||||
@ -541,11 +541,7 @@ g_get_any_init (void)
|
|||||||
if (pw)
|
if (pw)
|
||||||
{
|
{
|
||||||
g_user_name = g_strdup (pw->pw_name);
|
g_user_name = g_strdup (pw->pw_name);
|
||||||
#ifdef HAVE_PW_GECOS
|
|
||||||
g_real_name = g_strdup (pw->pw_gecos);
|
g_real_name = g_strdup (pw->pw_gecos);
|
||||||
#else
|
|
||||||
g_real_name = g_strdup (g_user_name);
|
|
||||||
#endif
|
|
||||||
if (!g_home_dir)
|
if (!g_home_dir)
|
||||||
g_home_dir = g_strdup (pw->pw_dir);
|
g_home_dir = g_strdup (pw->pw_dir);
|
||||||
}
|
}
|
||||||
|
13
testglib.c
13
testglib.c
@ -77,7 +77,7 @@ g_node_test (void)
|
|||||||
GNode *node_G;
|
GNode *node_G;
|
||||||
GNode *node_J;
|
GNode *node_J;
|
||||||
guint i;
|
guint i;
|
||||||
gchar *tstring;
|
gchar *tstring, *cstring;
|
||||||
|
|
||||||
g_print ("checking n-way trees: ");
|
g_print ("checking n-way trees: ");
|
||||||
failed = FALSE;
|
failed = FALSE;
|
||||||
@ -166,6 +166,17 @@ g_node_test (void)
|
|||||||
TEST (tstring, strcmp (tstring, "ABFEDCGKJIH") == 0);
|
TEST (tstring, strcmp (tstring, "ABFEDCGKJIH") == 0);
|
||||||
g_free (tstring); tstring = NULL;
|
g_free (tstring); tstring = NULL;
|
||||||
|
|
||||||
|
cstring = NULL;
|
||||||
|
node = g_node_copy (root);
|
||||||
|
TEST (NULL, g_node_n_nodes (root, G_TRAVERSE_ALL) == g_node_n_nodes (node, G_TRAVERSE_ALL));
|
||||||
|
TEST (NULL, g_node_max_height (root) == g_node_max_height (node));
|
||||||
|
g_node_traverse (root, G_IN_ORDER, G_TRAVERSE_ALL, -1, node_build_string, &tstring);
|
||||||
|
g_node_traverse (node, G_IN_ORDER, G_TRAVERSE_ALL, -1, node_build_string, &cstring);
|
||||||
|
TEST (cstring, strcmp (tstring, cstring) == 0);
|
||||||
|
g_free (tstring); tstring = NULL;
|
||||||
|
g_free (cstring); cstring = NULL;
|
||||||
|
g_node_destroy (node);
|
||||||
|
|
||||||
g_node_destroy (root);
|
g_node_destroy (root);
|
||||||
|
|
||||||
/* allocation tests */
|
/* allocation tests */
|
||||||
|
@ -77,7 +77,7 @@ g_node_test (void)
|
|||||||
GNode *node_G;
|
GNode *node_G;
|
||||||
GNode *node_J;
|
GNode *node_J;
|
||||||
guint i;
|
guint i;
|
||||||
gchar *tstring;
|
gchar *tstring, *cstring;
|
||||||
|
|
||||||
g_print ("checking n-way trees: ");
|
g_print ("checking n-way trees: ");
|
||||||
failed = FALSE;
|
failed = FALSE;
|
||||||
@ -166,6 +166,17 @@ g_node_test (void)
|
|||||||
TEST (tstring, strcmp (tstring, "ABFEDCGKJIH") == 0);
|
TEST (tstring, strcmp (tstring, "ABFEDCGKJIH") == 0);
|
||||||
g_free (tstring); tstring = NULL;
|
g_free (tstring); tstring = NULL;
|
||||||
|
|
||||||
|
cstring = NULL;
|
||||||
|
node = g_node_copy (root);
|
||||||
|
TEST (NULL, g_node_n_nodes (root, G_TRAVERSE_ALL) == g_node_n_nodes (node, G_TRAVERSE_ALL));
|
||||||
|
TEST (NULL, g_node_max_height (root) == g_node_max_height (node));
|
||||||
|
g_node_traverse (root, G_IN_ORDER, G_TRAVERSE_ALL, -1, node_build_string, &tstring);
|
||||||
|
g_node_traverse (node, G_IN_ORDER, G_TRAVERSE_ALL, -1, node_build_string, &cstring);
|
||||||
|
TEST (cstring, strcmp (tstring, cstring) == 0);
|
||||||
|
g_free (tstring); tstring = NULL;
|
||||||
|
g_free (cstring); cstring = NULL;
|
||||||
|
g_node_destroy (node);
|
||||||
|
|
||||||
g_node_destroy (root);
|
g_node_destroy (root);
|
||||||
|
|
||||||
/* allocation tests */
|
/* allocation tests */
|
||||||
|
Loading…
Reference in New Issue
Block a user