|
From: <enl...@li...> - 2001-05-03 21:49:33
|
Enlightenment CVS committal
Author : rbdpngn
Project : e17
Module : libs/ewd
Dir : e17/libs/ewd/src
Modified Files:
ewd_list.c
Log Message:
Fixup in removing the last item from the list.
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewd/src/ewd_list.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- ewd_list.c 2001/05/02 22:58:02 1.5
+++ ewd_list.c 2001/05/03 21:49:03 1.6
@@ -477,8 +477,7 @@
void *_ewd_list_remove_last(Ewd_List * list)
{
void *ret = NULL;
- int index;
- Ewd_List_Node *old;
+ Ewd_List_Node *old, *prev;
if (!list)
return FALSE;
@@ -490,16 +489,13 @@
return FALSE;
old = list->last;
- if (list->current == list->last)
- index = list->nodes - 1;
+ for (prev = list->first; prev && prev->next != old; prev = prev->next);
+ if (prev) {
+ prev->next = NULL;
+ list->last = prev;
+ }
else
- index = ewd_list_index(list);
-
- _ewd_list_goto_index(list, list->nodes - 1);
- list->last = list->current;
- list->current->next = NULL;
-
- _ewd_list_goto_index(list, index);
+ list->first = list->current = list->last = NULL;
EWD_WRITE_LOCK_STRUCT(old);
if (old) {
@@ -858,7 +854,7 @@
EWD_WRITE_LOCK_STRUCT(node);
- if (free_func)
+ if (free_func && node->data)
free_func(node->data);
EWD_WRITE_UNLOCK_STRUCT(node);
|