Enlightenment CVS committal
Author : raster
Project : e17
Module : libs/evas
Dir : e17/libs/evas/src/lib/data
Modified Files:
evas_list.c
Log Message:
fix list bug...
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/evas/src/lib/data/evas_list.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -3 -r1.12 -r1.13
--- evas_list.c 25 Feb 2005 15:31:52 -0000 1.12
+++ evas_list.c 21 Apr 2005 08:28:21 -0000 1.13
@@ -772,44 +772,51 @@
static Evas_List *
evas_list_combine(Evas_List *l, Evas_List *ll, int (*func)(void *, void*))
{
- Evas_List *result = NULL;
- Evas_List *l_head = NULL, *ll_head = NULL;
-
- l_head = l;
- ll_head = ll;
- while(l && ll)
- {
- switch(func(l->data, ll->data))
- {
- case -1:
- result = evas_list_append(result, l->data);
- l = evas_list_next(l);
- break;
- case 0:
- result = evas_list_append(result, l->data);
- l = evas_list_next(l);
- result = evas_list_append(result, ll->data);
- ll = evas_list_next(ll);
- break;
- case 1:
- result = evas_list_append(result, ll->data);
- ll = evas_list_next(ll);
- break;
- }
- }
- while(l)
- {
+ Evas_List *result = NULL;
+ Evas_List *l_head = NULL, *ll_head = NULL;
+
+ l_head = l;
+ ll_head = ll;
+ while (l && ll)
+ {
+ int cmp;
+
+ cmp = func(l->data, ll->data);
+ if (cmp < 0)
+ {
+ result = evas_list_append(result, l->data);
+ l = evas_list_next(l);
+ }
+ else if (cmp == 0)
+ {
+ result = evas_list_append(result, l->data);
+ l = evas_list_next(l);
+ result = evas_list_append(result, ll->data);
+ ll = evas_list_next(ll);
+ }
+ else if (cmp > 0)
+ {
+ result = evas_list_append(result, ll->data);
+ ll = evas_list_next(ll);
+ }
+ else
+ {
+ l = ll = NULL;
+ }
+ }
+ while (l)
+ {
result = evas_list_append(result, l->data);
l = evas_list_next(l);
- }
- evas_list_free(l_head);
- while(ll)
- {
+ }
+ evas_list_free(l_head);
+ while (ll)
+ {
result = evas_list_append(result, ll->data);
ll = evas_list_next(ll);
- }
- evas_list_free(ll_head);
- return(result);
+ }
+ evas_list_free(ll_head);
+ return (result);
}
/**
@@ -853,38 +860,38 @@
Evas_List *
evas_list_sort(Evas_List *list, int size, int (*func)(void *, void *))
{
- Evas_List *l = NULL, *ll = NULL;
- int mid;
-
- if (!list || !func)
- return NULL;
-
- /* if the caller specified an invalid size, sort the whole list */
- if (size <= 0 || size > list->count)
- size = list->count;
-
- mid = size / 2;
- if (mid < 1)
- return list;
-
- /* bleh evas list splicing */
- ll = evas_list_nth_list(list, mid);
- if (ll->prev)
- {
- list->last = ll->prev;
- list->count = mid;
- ll->prev->next = NULL;
- ll->prev = NULL;
- }
-
- ll->count = size - mid;
-
- /* merge sort */
- l = evas_list_sort(list, mid, func);
- ll = evas_list_sort(ll, size - mid, func);
- list = evas_list_combine(l, ll, func);
-
- return(list);
+ Evas_List *l = NULL, *ll = NULL;
+ int mid;
+
+ if (!list || !func)
+ return NULL;
+
+ /* if the caller specified an invalid size, sort the whole list */
+ if (size <= 0 || size > list->count)
+ size = list->count;
+
+ mid = size / 2;
+ if (mid < 1)
+ return list;
+
+ /* bleh evas list splicing */
+ ll = evas_list_nth_list(list, mid);
+ if (ll->prev)
+ {
+ list->last = ll->prev;
+ list->count = mid;
+ ll->prev->next = NULL;
+ ll->prev = NULL;
+ }
+
+ ll->count = size - mid;
+
+ /* merge sort */
+ l = evas_list_sort(list, mid, func);
+ ll = evas_list_sort(ll, size - mid, func);
+ list = evas_list_combine(l, ll, func);
+
+ return(list);
}
/**
* Return the memory allocation failure flag after any operation needin
allocation
-------------------------------------------------------
This SF.Net email is sponsored by: New Crystal Reports XI.
Version 11 adds new functionality designed to reduce time involved in
creating, integrating, and deploying reporting solutions. Free runtime info,
new features, or free trial, at: http://www.businessobjects.com/devxi/728
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs