Code

llist utils: Added sdb_llist_remove_by_name().
[sysdb.git] / src / include / utils / llist.h
index 2742139f17db051d12b36c279889ff0c0bbfb48f..f557c9d41c63800ead40925f1414b7da02d80334 100644 (file)
@@ -119,6 +119,15 @@ int
 sdb_llist_insert_sorted(sdb_llist_t *list,
                sdb_object_t *obj, sdb_llist_cmp_cb);
 
+/*
+ * sdb_llist_get:
+ * 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);
+
 /*
  * sdb_llist_search:
  * Search for a object in the given 'list'. The function will return the first
@@ -148,9 +157,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
@@ -160,6 +169,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
@@ -203,6 +225,13 @@ sdb_llist_iter_get_next(sdb_llist_iter_t *iter);
 int
 sdb_llist_iter_remove_current(sdb_llist_iter_t *iter);
 
+/*
+ * sdb_llist_len:
+ * Return the length (number of elements) of the list.
+ */
+size_t
+sdb_llist_len(sdb_llist_t *list);
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif