Enlightenment CVS committal Author : kwo Project : e16 Module : e
Dir : e16/e/src Modified Files: e16-ecore_list.c e16-ecore_list.h Log Message: Fix build with ecore (ecore_list_find implemented in ecore). =================================================================== RCS file: /cvs/e/e16/e/src/e16-ecore_list.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- e16-ecore_list.c 25 Jul 2006 02:01:31 -0000 1.6 +++ e16-ecore_list.c 28 Dec 2006 10:24:53 -0000 1.7 @@ -105,6 +105,9 @@ static int _ecore_list_for_each(Ecore_List * list, Ecore_For_Each function, void *user_data); +static void *_ecore_list_find(Ecore_List * list, + Ecore_Compare_Cb function, + const void *user_data); /** * @defgroup Ecore_Data_List_Creation_Group List Creation/Destruction Functions @@ -276,9 +279,7 @@ _ecore_list_append_0(Ecore_List * list, Ecore_List_Node * end) { if (list->last) - { - list->last->next = end; - } + list->last->next = end; list->last = end; @@ -585,9 +586,7 @@ { prev->next = NULL; if (list->current == old) - { - list->current = NULL; - } + list->current = NULL; } if (old) @@ -897,11 +896,44 @@ return TRUE; } +/** + * Find data in @p list using the compare function @p func + * @param list The list. + * @param function The function to test each node of @p list with + * @param user_data Data to match against (used by @p function) + * @return the first matching data node, or NULL if none match + */ +EAPI void * +ecore_list_find(Ecore_List * list, Ecore_Compare_Cb function, + const void *user_data) +{ + CHECK_PARAM_POINTER_RETURN("list", list, NULL); + + return _ecore_list_find(list, function, user_data); +} + +/* The real meat of finding a node via a compare cb */ +static void * +_ecore_list_find(Ecore_List * list, Ecore_Compare_Cb function, + const void *user_data) +{ + void *value; + + if (!list || !function) + return NULL; + + _ecore_list_goto_first(list); + while ((value = _ecore_list_next(list)) != NULL) + if (!function(value, user_data)) + return value; + + return NULL; +} + /* Initialize a node to starting values */ EAPI int ecore_list_node_init(Ecore_List_Node * node) { - CHECK_PARAM_POINTER_RETURN("node", node, FALSE); node->next = NULL; @@ -963,21 +995,6 @@ /* * E16 additions */ - -EAPI void * -ecore_list_find(Ecore_List * list, Ecore_Match function, const void *match) -{ - void *data; - - if (!list || !function) - return NULL; - - for (_ecore_list_goto_first(list); (data = _ecore_list_next(list)) != NULL;) - if (!function(data, match)) - return data; - - return NULL; -} EAPI void * ecore_list_remove_node(Ecore_List * list, void *_data) =================================================================== RCS file: /cvs/e/e16/e/src/e16-ecore_list.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- e16-ecore_list.h 27 Feb 2006 19:34:49 -0000 1.3 +++ e16-ecore_list.h 28 Dec 2006 10:24:53 -0000 1.4 @@ -45,6 +45,7 @@ typedef struct _ecore_list Ecore_List; typedef struct _ecore_list_node Ecore_List_Node; +typedef int (*Ecore_Compare_Cb) (const void *data, const void *match); typedef void (*Ecore_For_Each) (void *value, void *user_data); typedef void (*Ecore_Free_Cb) (void *data); @@ -79,6 +80,9 @@ /* Traversing the list and returning data */ EAPI void *ecore_list_next(Ecore_List * list); +EAPI void *ecore_list_find(Ecore_List * list, + Ecore_Compare_Cb function, + const void *match); /* Check to see if there is any data in the list */ EAPI int ecore_list_is_empty(Ecore_List * list); @@ -106,11 +110,7 @@ #define ECORE_LIST_FOR_EACH(list, p) \ for (ecore_list_goto_first(list); (p = ecore_list_next(list)) != NULL;) -typedef int (*Ecore_Match) (const void *data, const void *match); - EAPI void *ecore_list_remove_node(Ecore_List * list, void *_data); -EAPI void *ecore_list_find(Ecore_List * list, - Ecore_Match function, const void *match); EAPI void **ecore_list_items_get(Ecore_List * list, int *pnum); #endif /* _E16_ECORE_LIST_H_ */ ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs