summaryrefslogtreecommitdiff
path: root/glist.c
diff options
context:
space:
mode:
authorTim Janik <timj@gtk.org>1998-11-23 01:52:07 +0000
committerTim Janik <timj@src.gnome.org>1998-11-23 01:52:07 +0000
commit70a6dbff8767b9a836e6d62411d5d4450cc884fc (patch)
tree02b50d55b05c6f20411dbfaf266edb443ac454a0 /glist.c
parent3556db20549c3d2a7d0ccc6552433cafc3fae4a5 (diff)
new function g_slist_copy() to duplicate a list with all its data
Sun Nov 22 17:07:03 1998 Tim Janik <timj@gtk.org> * glib.h: * gslist.c: new function g_slist_copy() to duplicate a list with all its data pointers. * glist.c: new function g_list_copy.
Diffstat (limited to 'glist.c')
-rw-r--r--glist.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/glist.c b/glist.c
index eaa77d82c..ee9ad695c 100644
--- a/glist.c
+++ b/glist.c
@@ -274,6 +274,32 @@ g_list_remove_link (GList *list,
}
GList*
+g_list_copy (GList *list)
+{
+ GList *new_list = NULL;
+
+ if (list)
+ {
+ GList *last;
+
+ new_list = g_list_alloc ();
+ new_list->data = list->data;
+ last = new_list;
+ list = list->next;
+ while (list)
+ {
+ last->next = g_list_alloc ();
+ last->next->prev = last;
+ last = last->next;
+ last->data = list->data;
+ list = list->next;
+ }
+ }
+
+ return new_list;
+}
+
+GList*
g_list_reverse (GList *list)
{
GList *last;