ListInsertL
- Macro
- October 8, 2025
Table of Contents
ListInsertL
ListInsertL
Description
Insert an l-value
into list of it’s type. Insertion index must not exceed list length.
Info
If copy_init
is set, then vector will create it’s own copy of items. If copy_init
is not set, then provided l-value will be memset to 0 to keep unique ownership.
Note
Ownership of item is transferred to list if no copy_init
method is set. This is to prevent multiple ownership of same object, once inserted into list. Object may not be usable after this call if copy_init
is not set.
Parameters
Name | Direction | Description |
---|---|---|
l | in,out | List to insert item into |
lval | in | l-value to be inserted |
idx | in | Index to insert item at. |
Usage example (from documentation)
// the data
int x = 10;
int y = 20;
// vector
List(int) integers = ListInit();
// insert items
ListInsertL(&integers, x, 0); // x = 0 now, unlike x = 10 in ListInsertR
ListInsertL(&integers, y, 0); // y = 0 now, unlike y = 20 in ListInsertR
ListInsertL(&integers, LVAL(101), 1); // took a r-value, and converted to l-value on spot
// better use ListInsertR in this last case though, otherwise there'll be an extra useless function call
Success
return
Failure
Does not return
Usage example (Cross-references)
- In
Insert.h:98
:
/// FAILURE: Does not return
///
#define ListInsert(l, lval, idx) ListInsertL((l), (lval), (idx))
///
- In
Insert.h:111
:
/// FAILURE: Does not return.
///
#define ListPushFrontL(l, lval) ListInsertL((l), (lval), 0);
///
- In
Insert.h:124
:
/// FAILURE: Does not return
///
#define ListPushBackL(l, lval) ListInsertL((l), (lval), (l)->length)
///