diff options
author | Manish Singh <yosh@src.gnome.org> | 1998-01-27 09:42:41 +0000 |
---|---|---|
committer | Manish Singh <yosh@src.gnome.org> | 1998-01-27 09:42:41 +0000 |
commit | 8f355e26ef034ed70a56f13830ab919fab8b86d5 (patch) | |
tree | 108b2dd4e5556f87011399ea09ba9ae1d1887c55 /glib | |
parent | 3cefe524dc3e3a0406953949fd6ff58cd2914c85 (diff) | |
download | gtk+-8f355e26ef034ed70a56f13830ab919fab8b86d5.tar.gz |
Fixed a really lame error where g_slist_insert didn't hook the data
in! Reworked the routine a bit too.
-Yosh
Diffstat (limited to 'glib')
-rw-r--r-- | glib/ChangeLog | 6 | ||||
-rw-r--r-- | glib/gslist.c | 42 |
2 files changed, 29 insertions, 19 deletions
diff --git a/glib/ChangeLog b/glib/ChangeLog index eeba0a4a92..e19a24669c 100644 --- a/glib/ChangeLog +++ b/glib/ChangeLog @@ -1,3 +1,9 @@ +Tue Jan 27 01:38:52 PST 1998 Manish Singh <yosh@gimp.org> + + * gslist.c: fixed a really, really lame error. g_slist_insert + didn't hook the data in! Reworked the routine to reflect the + functionality of g_list + Wed Jan 21 01:13:25 1998 Tim Janik <timj@psynet.net> * Applied patch from (Raja R Harinath <harinath@cs.umn.edu>) diff --git a/glib/gslist.c b/glib/gslist.c index 248bfdb99a..f1a6fddaed 100644 --- a/glib/gslist.c +++ b/glib/gslist.c @@ -110,18 +110,16 @@ g_slist_append (GSList *list, new_list = g_slist_alloc (); new_list->data = data; - if (!list) - { - list = new_list; - } - else + if (list) { last = g_slist_last (list); - g_assert (last != NULL); + /* g_assert (last != NULL); */ last->next = new_list; - } - return list; + return list; + } + else + return new_list; } GSList* @@ -146,29 +144,35 @@ g_slist_insert (GSList *list, GSList *tmp_list; GSList *new_list; + if (position < 0) + return g_slist_append (list, data); + else if (position == 0) + return g_slist_prepend (list, data); + + new_list = g_slist_alloc (); + new_list->data = data; + + if (!list) + return new_list; + prev_list = NULL; tmp_list = list; - while (tmp_list && (position-- > 0)) + while ((position-- > 0) && tmp_list) { prev_list = tmp_list; tmp_list = tmp_list->next; } - if (!tmp_list && !prev_list) - return list; - - new_list = g_slist_alloc (); - - if (!prev_list) + if (prev_list) { - new_list->next = list; - list = new_list; + new_list->next = prev_list->next; + prev_list->next = new_list; } else { - new_list->next = prev_list->next; - prev_list->next = new_list; + new_list->next = list; + list = new_list; } return list; |