libyang  3.6.0
libyang is YANG data modelling language parser and toolkit written (and providing API) in C.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures

Sized Arrays

The structure starts with 32bit number storing size of the array - the number of the items inside. The size is part of the array to have it allocated together with the array itself only when it is needed. However, the pointers to the array always points after the 32b number, so items can be accessed directly as for standard C arrays. Because of a known size (available via LY_ARRAY_COUNT macro), it is not terminated by any special byte (sequence), so there is also no limitation for specific content of the stored records (e.g. that first byte must not be NULL).

The sized arrays must be carefully freed (which should be done anyway only internally), since pointers to the sized arrays used in libyang structures, does not point to the beginning of the allocated space.

Lists

The lists are structures connected via a next and prev pointers. Iterating over the siblings can be simply done by LY_LIST_FOR macro. Examples of such structures are lyd_node or lysc_node.

The prev pointer is always filled. In case there is just a single item in the list, the prev pointer points to the item itself. Otherwise, the prev pointer of the first item points to the last item of the list. In contrast, the next pointer of the last item in the list is always NULL.