The following iteration macros work across all data structures:
-.. c:function:: frr_each(Z, &head, item)
+.. c:macro:: frr_each(Z, head, item)
Equivalent to:
Note that this will fail if the list is modified while being iterated
over.
-.. c:function:: frr_each_safe(Z, &head, item)
+.. c:macro:: frr_each_safe(Z, head, item)
Same as the previous, but the next element is pre-loaded into a "hidden"
variable (named ``Z_safe``.) Equivalent to:
tables is resized while iterating. This will cause items to be
skipped or iterated over twice.
-.. c:function:: frr_each_from(Z, &head, item, from)
+.. c:macro:: frr_each_from(Z, head, item, from)
Iterates over the list, starting at item ``from``. This variant is "safe"
as in the previous macro. Equivalent to:
``item`` must not be ``NULL`` for any of the following functions.
-.. c:function:: DECLARE_XXX(Z, type, field)
+.. c:macro:: DECLARE_XXX(Z, type, field)
:param listtype XXX: ``LIST``, ``DLIST`` or ``ATOMLIST`` to select a data
structure implementation.
therefore the insertion calls are different from unsorted lists. Also,
sorted lists can be searched for a value.
-.. c:function:: DECLARE_XXX_UNIQ(Z, type, field, compare_func)
+.. c:macro:: DECLARE_XXX_UNIQ(Z, type, field, compare_func)
:param listtype XXX: One of the following:
``SORTLIST`` (single-linked sorted list), ``SKIPLIST`` (skiplist),
``int function(const itemtype *, const itemtype*)``. This function
may be static if the list is only used in one file.
-.. c:function:: DECLARE_XXX_NONUNIQ(Z, type, field, compare_func)
+.. c:macro:: DECLARE_XXX_NONUNIQ(Z, type, field, compare_func)
Same as above, but allow adding multiple items to the list that compare
as equal in ``compare_func``. Ordering between these items is undefined
API for hash tables
-------------------
-.. c:function:: DECLARE_XXX(Z, type, field, compare_func, hash_func)
+.. c:macro:: DECLARE_HASH(Z, type, field, compare_func, hash_func)
- :param listtype XXX: Only ``HASH`` is currently available.
+ :param listtype HASH: Only ``HASH`` is currently available.
:param token Z: Gives the name prefix that is used for the functions
created for this instantiation. ``DECLARE_XXX(foo, ...)``
gives ``struct foo_item``, ``foo_add()``, ``foo_count()``, etc. Note
``pthread_mutex_unlock``. Use ``#include "frr_pthread.h"`` to get these
macros.
-.. c:function:: frr_with_mutex(pthread_mutex_t *mutex)
+.. c:macro:: frr_with_mutex(mutex)
+
+ (With ``pthread_mutex_t *mutex``.)
Begin a C statement block that is executed with the mutex locked. Any
exit from the block (``break``, ``return``, ``goto``, end of block) will
statement works correctly, FRR coding style requires that this macro always
be used with a ``{ ... }`` block.
-.. c:function:: frr_mutex_lock_autounlock(pthread_mutex_t *mutex)
+.. c:macro:: frr_mutex_lock_autounlock(mutex)
+
+ (With ``pthread_mutex_t *mutex``.)
Lock mutex and unlock at the end of the current C statement block::