ListInsert
Description
Default insert aliases the L-form: link a new node holding lval’s payload at position idx, taking ownership of lval when no deep-copy handler is configured.
Parameters
| Name | Direction | Description |
|---|---|---|
l |
in,out | List handle. |
lval |
in | Addressable element to insert. Must match the list’s element type. |
idx |
in | Position in [0, length]. |
Success
Returns true; the list length grows by one.
Failure
Returns false on allocation failure; the list and lval are unchanged.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
List.Insert.c:63:
ListInsertL(&list, a, 0);
ListInsertR(&list, b, 1);
ListInsert(&list, c, 1);
ListPushFrontL(&list, d);
ListPushFrontR(&list, h);- In
Insert.h:329:
#define ListMustInsert(l, lval, idx) \
do { \
if (!ListInsert((l), (lval), (idx))) { \
LOG_FATAL("ListMustInsert failed"); \
} \
Last updated on