libyang-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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值