X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Finclude%2Futils%2Fllist.h;h=28816a6a49abaaf58232f55ab5b7e9a9f6a2ffa8;hb=56b97a180a53aecbfe9f7162b8ece3faae973cf9;hp=3eefae5e19b894adf457a5d195e7840a11f79757;hpb=ea29adb896a47f32e86119d6161dc5bc2259565b;p=sysdb.git diff --git a/src/include/utils/llist.h b/src/include/utils/llist.h index 3eefae5..28816a6 100644 --- a/src/include/utils/llist.h +++ b/src/include/utils/llist.h @@ -56,6 +56,14 @@ sdb_llist_create(void); void sdb_llist_destroy(sdb_llist_t *list); +/* + * sdb_llist_clear: + * Remove all elements from the list, releasing the included objects + * (decrement the ref-count). + */ +void +sdb_llist_clear(sdb_llist_t *list); + /* * sdb_llist_clone: * Clone an existing list. The objects stored in the list will not be copied @@ -121,7 +129,9 @@ sdb_llist_insert_sorted(sdb_llist_t *list, /* * sdb_llist_get: - * Returns the i-th element of the list or NULL in case of an error. + * Returns the i-th element of the list or NULL in case of an error. The + * reference count of the element is incremented before returning it to share + * ownership between the list and the caller. */ sdb_object_t * sdb_llist_get(sdb_llist_t *list, size_t i); @@ -155,9 +165,9 @@ sdb_llist_search_by_name(sdb_llist_t *list, const char *key); /* * sdb_llist_remove: - * Removes and returns the first matchin element of the list. The ref-count of - * the item will not be changed, that is, if the element will not be used any - * further, it should be de-referenced by the caller. + * Removes and returns the first matching element of the list. The ref-count + * of the item will not be changed, that is, if the element will not be used + * any further, it should be de-referenced by the caller. * * Returns: * - a pointer to the first matching object @@ -167,6 +177,19 @@ sdb_object_t * sdb_llist_remove(sdb_llist_t *list, sdb_llist_lookup_cb lookup, const void *user_data); +/* + * sdb_llist_remove_by_name: + * Removes and returns the first element whose name matches the specified key. + * The ref-count of the item will not be changed, that is, if the element will + * not be used any further, it should be de-referenced by the caller. + * + * Returns: + * - a pointer to the first matching object + * - NULL else + */ +sdb_object_t * +sdb_llist_remove_by_name(sdb_llist_t *list, const char *key); + /* * sdb_llist_shift: * Removes and returns the first element of the list. The ref-count of the