From: Sebastian Harl Date: Wed, 25 Sep 2013 20:11:20 +0000 (+0200) Subject: utils llist: Added sdb_llist_cmp_cb type. X-Git-Tag: sysdb-0.1.0~341 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=be8fe81410d8f9b14debc388248d233b95b26a2d;p=sysdb.git utils llist: Added sdb_llist_cmp_cb type. This is to make sure that comparators always use the same signature. --- diff --git a/src/include/utils/llist.h b/src/include/utils/llist.h index c37c271..4bf9d60 100644 --- a/src/include/utils/llist.h +++ b/src/include/utils/llist.h @@ -40,6 +40,8 @@ typedef struct sdb_llist sdb_llist_t; struct sdb_llist_iter; typedef struct sdb_llist_iter sdb_llist_iter_t; +typedef int (*sdb_llist_cmp_cb)(const sdb_object_t *, const sdb_object_t *); + /* * sdb_llist_create, sdb_llist_destroy: * Create and destroy a doubly linked list object. @@ -113,8 +115,8 @@ sdb_llist_insert(sdb_llist_t *list, sdb_object_t *obj, size_t idx); * - a negative value on failure */ int -sdb_llist_insert_sorted(sdb_llist_t *list, sdb_object_t *obj, - int (*compare)(const sdb_object_t *, const sdb_object_t *)); +sdb_llist_insert_sorted(sdb_llist_t *list, + sdb_object_t *obj, sdb_llist_cmp_cb); /* * sdb_llist_search: @@ -127,8 +129,8 @@ sdb_llist_insert_sorted(sdb_llist_t *list, sdb_object_t *obj, * - NULL else */ sdb_object_t * -sdb_llist_search(sdb_llist_t *list, const sdb_object_t *key, - int (*compare)(const sdb_object_t *, const sdb_object_t *)); +sdb_llist_search(sdb_llist_t *list, + const sdb_object_t *key, sdb_llist_cmp_cb); /* * sdb_llist_search_by_name: diff --git a/src/utils/llist.c b/src/utils/llist.c index b606324..dfc8fb9 100644 --- a/src/utils/llist.c +++ b/src/utils/llist.c @@ -262,8 +262,8 @@ sdb_llist_insert(sdb_llist_t *list, sdb_object_t *obj, size_t idx) } /* sdb_llist_insert */ int -sdb_llist_insert_sorted(sdb_llist_t *list, sdb_object_t *obj, - int (*compare)(const sdb_object_t *, const sdb_object_t *)) +sdb_llist_insert_sorted(sdb_llist_t *list, + sdb_object_t *obj, sdb_llist_cmp_cb compare) { sdb_llist_elem_t *prev; sdb_llist_elem_t *next; @@ -291,8 +291,8 @@ sdb_llist_insert_sorted(sdb_llist_t *list, sdb_object_t *obj, } /* sdb_llist_insert_sorted */ sdb_object_t * -sdb_llist_search(sdb_llist_t *list, const sdb_object_t *key, - int (*compare)(const sdb_object_t *, const sdb_object_t *)) +sdb_llist_search(sdb_llist_t *list, + const sdb_object_t *key, sdb_llist_cmp_cb compare) { sdb_llist_elem_t *elem;