ListPushArrR
Description
Append a contiguous range of elements to the end of the list. R-value form.
Success
Returns true. count new nodes holding copies of the source elements are linked at the tail; list length grows by count. The source range is untouched.
Failure
Returns false on allocation failure during the first node allocation. The list and source are unchanged.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Insert.h:468:
#define ListMustPushArrR(l, arr, count) \
do { \
if (!ListPushArrR((l), (arr), (count))) { \
LOG_FATAL("ListMustPushArrR failed"); \
} \ // and the values landed.
static bool test_push_arr_r_actually_inserts(void) {
WriteFmt("Testing ListPushArrR actually appends the source range\n");
DefaultAllocator alloc = DefaultAllocatorInit(); int arr[] = {7, 8, 9};
bool ok = ListPushArrR(&list, arr, 3);
bool result = ok && (ListLen(&list) == 3);
result = result && (ListAt(&list, 0) == 7);
int src[3] = {7, 8, 9};
bool returned = ListPushArrR(&list, src, 3);
bool result = (returned == false);
Last updated on