mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-07 15:33:56 +00:00
doc: Some minor doc cleanup for new data structures
Noticed during attempts at usage that the documentation needed a couple small updates: 1) Tell the user which header to include 2) Some functions want the address of the data structure Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
5390986617
commit
820b3b6596
@ -119,6 +119,8 @@ The common setup pattern will look like this:
|
|||||||
|
|
||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
|
|
||||||
|
#include <typesafe.h>
|
||||||
|
|
||||||
PREDECL_XXX(Z)
|
PREDECL_XXX(Z)
|
||||||
struct item {
|
struct item {
|
||||||
int otherdata;
|
int otherdata;
|
||||||
@ -159,26 +161,26 @@ Common iteration macros
|
|||||||
|
|
||||||
The following iteration macros work across all data structures:
|
The following iteration macros work across all data structures:
|
||||||
|
|
||||||
.. c:function:: for_each(Z, head, item)
|
.. c:function:: for_each(Z, &head, item)
|
||||||
|
|
||||||
Equivalent to:
|
Equivalent to:
|
||||||
|
|
||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
|
|
||||||
for (item = Z_first(head); item; item = Z_next(head, item))
|
for (item = Z_first(&head); item; item = Z_next(&head, item))
|
||||||
|
|
||||||
Note that this will fail if the list is modified while being iterated
|
Note that this will fail if the list is modified while being iterated
|
||||||
over.
|
over.
|
||||||
|
|
||||||
.. c:function:: for_each_safe(Z, head, item)
|
.. c:function:: for_each_safe(Z, &head, item)
|
||||||
|
|
||||||
Same as the previous, but the next element is pre-loaded into a "hidden"
|
Same as the previous, but the next element is pre-loaded into a "hidden"
|
||||||
variable (named ``Z_safe``.) Equivalent to:
|
variable (named ``Z_safe``.) Equivalent to:
|
||||||
|
|
||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
|
|
||||||
for (item = Z_first(head); item; item = next) {
|
for (item = Z_first(&head); item; item = next) {
|
||||||
next = Z_next_safe(head, item);
|
next = Z_next_safe(&head, item);
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +191,7 @@ The following iteration macros work across all data structures:
|
|||||||
tables is resized while iterating. This will cause items to be
|
tables is resized while iterating. This will cause items to be
|
||||||
skipped or iterated over twice.
|
skipped or iterated over twice.
|
||||||
|
|
||||||
.. c:function:: for_each_from(Z, head, item, from)
|
.. c:function:: for_each_from(Z, &head, item, from)
|
||||||
|
|
||||||
Iterates over the list, starting at item ``from``. This variant is "safe"
|
Iterates over the list, starting at item ``from``. This variant is "safe"
|
||||||
as in the previous macro. Equivalent to:
|
as in the previous macro. Equivalent to:
|
||||||
@ -197,7 +199,7 @@ The following iteration macros work across all data structures:
|
|||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
|
|
||||||
for (item = from; item; item = from) {
|
for (item = from; item; item = from) {
|
||||||
from = Z_next_safe(head, item);
|
from = Z_next_safe(&head, item);
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user