Improve c_list_find functions.

This commit is contained in:
Andreas Schneider 2009-06-05 11:22:06 +02:00
parent f98265b30e
commit 312c40d16f
2 changed files with 8 additions and 8 deletions

View File

@ -338,7 +338,7 @@ c_list_t *c_list_position(c_list_t *list, long position) {
/*
* Finds the element in a c_list_t which contains the given data.
*/
c_list_t *c_list_find(c_list_t *list, void *data) {
c_list_t *c_list_find(c_list_t *list, const void *data) {
if (list == NULL) {
return NULL;
}
@ -356,13 +356,13 @@ c_list_t *c_list_find(c_list_t *list, void *data) {
* Finds an element, using a supplied function to find the desired
* element.
*/
c_list_t *c_list_find_custom(c_list_t *list, void *data,
c_list_compare_fn func) {
c_list_t *c_list_find_custom(c_list_t *list, const void *data,
c_list_compare_fn fn) {
int cmp;
if (list != NULL && func != NULL) {
if (list != NULL && fn != NULL) {
while (list != NULL) {
cmp = ((c_list_compare_fn) func) (list->data, data);
cmp = (*fn)(list->data, data);
if (cmp == 0) {
return list;
}

View File

@ -237,7 +237,7 @@ c_list_t *c_list_position(c_list_t *list, long position);
*
* @return The found element or NULL if it is not found.
*/
c_list_t *c_list_find(c_list_t *list, void *data);
c_list_t *c_list_find(c_list_t *list, const void *data);
/**
* Finds an element, using a supplied function to find the desired
@ -252,8 +252,8 @@ c_list_t *c_list_find(c_list_t *list, void *data);
*
* @return The found element or NULL if it is not found.
*/
c_list_t *c_list_find_custom(c_list_t *list, void *data,
c_list_compare_fn func);
c_list_t *c_list_find_custom(c_list_t *list, const void *data,
c_list_compare_fn fn);
/**
* Sorts the elements of a c_list.