Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=eff898f5d2d9ed48db0a3f9075c354faa21b73b4

commit eff898f5d2d9ed48db0a3f9075c354faa21b73b4
Author: Michel Hermier <[email protected]>
Date:   Mon May 13 12:50:34 2013 +0200

libflib: Rewrite f_list_insert_after/before, so they work properly (was not 
really tested before).

diff --git a/lib/libflib/flist.c b/lib/libflib/flist.c
index 977ba83..c3730dc 100644
--- a/lib/libflib/flist.c
+++ b/lib/libflib/flist.c
@@ -85,6 +85,9 @@ void f_list_set (FList *item, void *data) {
}
}

+/**
+ * Insert a @list after @item.
+ */
void f_list_insert_after (FList *item, FList *list) {
FList *last = f_list_last (list);

@@ -92,14 +95,17 @@ void f_list_insert_after (FList *item, FList *list) {
if (list == NULL) {
return;
}
-       list->prev = item;
last->next = item->next;
-       item->next = list;
if (last->next != NULL) {
last->next->prev = last;
}
+       item->next = list;
+       list->prev = item;
}

+/**
+ * Insert a @list before @item.
+ */
void f_list_insert_before (FList *item, FList *list) {
FList *last = f_list_last (list);

@@ -107,16 +113,16 @@ void f_list_insert_before (FList *item, FList *list) {
if (list == NULL) {
return;
}
-       last->next = item;
-       item->prev = last;
list->prev = item->prev;
-       if (item->prev != NULL) {
-               item->prev->next = list;
+       if (list->prev != NULL) {
+               list->prev->next = list;
}
+       last->next = item;
+       item->prev = last;
}

/**
- * Remove a list item from the list it belongs.
+ * Remove an @item from the list it belongs.
*/
void f_list_remove (FList *item) {
if (item != NULL) {
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to