comparison util.c @ 485:ad7ddce47878

Improve nn_userhash_foreach() by adding user data parameter.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 26 May 2012 15:30:46 +0300
parents 607bd4491e79
children 73f8df0ecffe
comparison
equal deleted inserted replaced
484:568bbf5e7091 485:ad7ddce47878
471 th_free(user->name); 471 th_free(user->name);
472 th_free(user); 472 th_free(user);
473 } 473 }
474 474
475 475
476 nn_user_t *nn_userhash_foreach(const nn_userhash_t *list, int (*func)(const nn_user_t *)) 476 nn_user_t *nn_userhash_foreach(const nn_userhash_t *list, int (*func)(const nn_user_t *, void *userdata), void *data)
477 { 477 {
478 int i; 478 int i;
479 479
480 if (list == NULL) return NULL; 480 if (list == NULL) return NULL;
481 481
483 if (list->buckets[i] != NULL) 483 if (list->buckets[i] != NULL)
484 { 484 {
485 nn_user_t *curr = list->buckets[i]; 485 nn_user_t *curr = list->buckets[i];
486 while (curr != NULL) 486 while (curr != NULL)
487 { 487 {
488 if (func(curr) != 0) 488 if (func(curr, data) != 0)
489 return curr; 489 return curr;
490 curr = curr->next; 490 curr = curr->next;
491 } 491 }
492 } 492 }
493 493