Fixed a really lame error where g_slist_insert didn't hook the data
in! Reworked the routine a bit too. -Yosh
This commit is contained in:
parent
3cefe524dc
commit
8f355e26ef
@ -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>
|
Wed Jan 21 01:13:25 1998 Tim Janik <timj@psynet.net>
|
||||||
|
|
||||||
* Applied patch from (Raja R Harinath <harinath@cs.umn.edu>)
|
* Applied patch from (Raja R Harinath <harinath@cs.umn.edu>)
|
||||||
|
@ -110,18 +110,16 @@ g_slist_append (GSList *list,
|
|||||||
new_list = g_slist_alloc ();
|
new_list = g_slist_alloc ();
|
||||||
new_list->data = data;
|
new_list->data = data;
|
||||||
|
|
||||||
if (!list)
|
if (list)
|
||||||
{
|
|
||||||
list = new_list;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
last = g_slist_last (list);
|
last = g_slist_last (list);
|
||||||
g_assert (last != NULL);
|
/* g_assert (last != NULL); */
|
||||||
last->next = new_list;
|
last->next = new_list;
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return new_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
GSList*
|
GSList*
|
||||||
@ -146,30 +144,36 @@ g_slist_insert (GSList *list,
|
|||||||
GSList *tmp_list;
|
GSList *tmp_list;
|
||||||
GSList *new_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;
|
prev_list = NULL;
|
||||||
tmp_list = list;
|
tmp_list = list;
|
||||||
|
|
||||||
while (tmp_list && (position-- > 0))
|
while ((position-- > 0) && tmp_list)
|
||||||
{
|
{
|
||||||
prev_list = tmp_list;
|
prev_list = tmp_list;
|
||||||
tmp_list = tmp_list->next;
|
tmp_list = tmp_list->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tmp_list && !prev_list)
|
if (prev_list)
|
||||||
return list;
|
|
||||||
|
|
||||||
new_list = g_slist_alloc ();
|
|
||||||
|
|
||||||
if (!prev_list)
|
|
||||||
{
|
|
||||||
new_list->next = list;
|
|
||||||
list = new_list;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
new_list->next = prev_list->next;
|
new_list->next = prev_list->next;
|
||||||
prev_list->next = new_list;
|
prev_list->next = new_list;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
new_list->next = list;
|
||||||
|
list = new_list;
|
||||||
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user