From 594f1fbbb1c6aa64368c01d92ab5d7533e4e9cfa Mon Sep 17 00:00:00 2001 From: Chantry Xavier Date: Sun, 2 Dec 2007 23:48:12 +0100 Subject: alpm_list : change the alpm_list_find* to return the matching item. alpm_list_find and alpm_list_find_ptr will now return a void *, and alpm_list_find_str will return a char *, instead of an int. Signed-off-by: Chantry Xavier Signed-off-by: Dan McGee --- lib/libalpm/alpm_list.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'lib/libalpm/alpm_list.c') diff --git a/lib/libalpm/alpm_list.c b/lib/libalpm/alpm_list.c index 69cd3479..a1e8861b 100644 --- a/lib/libalpm/alpm_list.c +++ b/lib/libalpm/alpm_list.c @@ -580,19 +580,19 @@ int SYMEXPORT alpm_list_count(const alpm_list_t *list) * @param haystack the list * @param fn the comparison function for searching (!= NULL) * - * @return 1 if `needle` is found, 0 otherwise + * @return `needle` if found, NULL otherwise */ -int SYMEXPORT alpm_list_find(const alpm_list_t *haystack, const void *needle, +void SYMEXPORT *alpm_list_find(const alpm_list_t *haystack, const void *needle, alpm_list_fn_cmp fn) { const alpm_list_t *lp = haystack; while(lp) { if(lp->data && fn(lp->data, needle) == 0) { - return(1); + return(lp->data); } lp = lp->next; } - return(0); + return(NULL); } /* trivial helper function for alpm_list_find_ptr */ @@ -609,9 +609,9 @@ static int ptrcmp(const void *p, const void *q) * @param needle the data to search for (== comparison) * @param haystack the list * - * @return 1 if `needle` is found, 0 otherwise + * @return `needle` if found, NULL otherwise */ -int SYMEXPORT alpm_list_find_ptr(const alpm_list_t *haystack, const void *needle) +void SYMEXPORT *alpm_list_find_ptr(const alpm_list_t *haystack, const void *needle) { return(alpm_list_find(haystack, needle, ptrcmp)); } @@ -622,11 +622,11 @@ int SYMEXPORT alpm_list_find_ptr(const alpm_list_t *haystack, const void *needle * @param needle the string to search for * @param haystack the list * - * @return 1 if `needle` is found, 0 otherwise + * @return `needle` if found, NULL otherwise */ -int SYMEXPORT alpm_list_find_str(const alpm_list_t *haystack, const char *needle) +char SYMEXPORT *alpm_list_find_str(const alpm_list_t *haystack, const char *needle) { - return(alpm_list_find(haystack, (const void*)needle, (alpm_list_fn_cmp)strcmp)); + return((char *)alpm_list_find(haystack, (const void*)needle, (alpm_list_fn_cmp)strcmp)); } /** -- cgit v1.2.3-24-g4f1b