From: Sebastian Harl Date: Sat, 5 Jul 2014 09:15:56 +0000 (+0200) Subject: Moved compare and lookup callback types from utils/llist to core/object. X-Git-Tag: sysdb-0.3.0~77 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3577da85f5922d92a078ec690b6a33dc16ae5433;p=sysdb.git Moved compare and lookup callback types from utils/llist to core/object. --- diff --git a/src/include/core/object.h b/src/include/core/object.h index 819d11e..42352b0 100644 --- a/src/include/core/object.h +++ b/src/include/core/object.h @@ -68,6 +68,12 @@ typedef struct { #define SDB_OBJ_WRAPPER(obj) ((sdb_object_wrapper_t *)(obj)) #define SDB_CONST_OBJ_WRAPPER(obj) ((const sdb_object_wrapper_t *)(obj)) +/* + * Callback types for comparing objects or performing object lookup. + */ +typedef int (*sdb_object_cmp_cb)(const sdb_object_t *, const sdb_object_t *); +typedef int (*sdb_object_lookup_cb)(const sdb_object_t *, const void *user_data); + /* * sdb_object_create: * Allocates a new sdb_object_t of the specified 'name' and 'type'. The object diff --git a/src/include/utils/llist.h b/src/include/utils/llist.h index 28816a6..1dddb7e 100644 --- a/src/include/utils/llist.h +++ b/src/include/utils/llist.h @@ -40,9 +40,6 @@ 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 *); -typedef int (*sdb_llist_lookup_cb)(const sdb_object_t *, const void *user_data); - /* * sdb_llist_create, sdb_llist_destroy: * Create and destroy a doubly linked list object. @@ -125,7 +122,7 @@ sdb_llist_insert(sdb_llist_t *list, sdb_object_t *obj, size_t idx); */ int sdb_llist_insert_sorted(sdb_llist_t *list, - sdb_object_t *obj, sdb_llist_cmp_cb); + sdb_object_t *obj, sdb_object_cmp_cb); /* * sdb_llist_get: @@ -148,7 +145,7 @@ sdb_llist_get(sdb_llist_t *list, size_t i); */ sdb_object_t * sdb_llist_search(sdb_llist_t *list, - sdb_llist_lookup_cb lookup, const void *user_data); + sdb_object_lookup_cb lookup, const void *user_data); /* * sdb_llist_search_by_name: @@ -175,7 +172,7 @@ sdb_llist_search_by_name(sdb_llist_t *list, const char *key); */ sdb_object_t * sdb_llist_remove(sdb_llist_t *list, - sdb_llist_lookup_cb lookup, const void *user_data); + sdb_object_lookup_cb lookup, const void *user_data); /* * sdb_llist_remove_by_name: diff --git a/src/utils/llist.c b/src/utils/llist.c index f9bf722..03ffd95 100644 --- a/src/utils/llist.c +++ b/src/utils/llist.c @@ -141,7 +141,7 @@ llist_insert_after(sdb_llist_t *list, sdb_llist_elem_t *elem, static sdb_llist_elem_t * llist_search(sdb_llist_t *list, - sdb_llist_lookup_cb lookup, const void *user_data) + sdb_object_lookup_cb lookup, const void *user_data) { sdb_llist_elem_t *elem; @@ -297,7 +297,7 @@ sdb_llist_insert(sdb_llist_t *list, sdb_object_t *obj, size_t idx) int sdb_llist_insert_sorted(sdb_llist_t *list, - sdb_object_t *obj, sdb_llist_cmp_cb compare) + sdb_object_t *obj, sdb_object_cmp_cb compare) { sdb_llist_elem_t *prev; sdb_llist_elem_t *next; @@ -343,7 +343,7 @@ sdb_llist_get(sdb_llist_t *list, size_t i) sdb_object_t * sdb_llist_search(sdb_llist_t *list, - sdb_llist_lookup_cb lookup, const void *user_data) + sdb_object_lookup_cb lookup, const void *user_data) { sdb_llist_elem_t *elem; @@ -382,7 +382,7 @@ sdb_llist_search_by_name(sdb_llist_t *list, const char *key) sdb_object_t * sdb_llist_remove(sdb_llist_t *list, - sdb_llist_lookup_cb lookup, const void *user_data) + sdb_object_lookup_cb lookup, const void *user_data) { sdb_llist_elem_t *elem; sdb_object_t *obj = NULL;