vppinfra: add more llist macros
[vpp.git] / src / vppinfra / llist.h
index 25fb95f..4281090 100644 (file)
@@ -51,6 +51,44 @@ typedef struct clib_llist_anchor
  * @return     pool entry index
  */
 #define clib_llist_entry_index(LP,E) ((E) - (LP))
+/**
+ * Alloc new element
+ *
+ * @param LP   linked list pool
+ * @param E    element to be returned
+ */
+#define clib_llist_get(LP, E) pool_get (LP, E)
+/**
+ * Free element
+ *
+ * @param LP   linked list pool
+ * @param E    element to be freed
+ */
+#define clib_llist_put(LP, E) pool_put (LP, E)
+/**
+ * Free list supporting container
+ *
+ * @param LP   linked list pool
+ */
+#define clib_llist_free(LP) pool_free (LP)
+/**
+ * Get list elt at index
+ *
+ * @param LP   linked list pool
+ * @param EI   element index
+ * @return     element
+ */
+#define clib_llist_elt(LP, EI) pool_elt_at_index (LP, EI)
+/**
+ * Get number of elements in supporting container
+ *
+ * This is NOT the elements linked in the list but the number of
+ * elements consumed out of the supporting pool
+ *
+ * @param LP   linked list pool
+ * @return     number of elements
+ */
+#define clib_llist_elts(LP) pool_elts (LP)
 /**
  * Get prev list entry index
  *