ListMergeL
Description
Append all elements of l2 to the end of l. L-value form: when the destination has no copy_init handler, ownership of l2’s storage transfers and l2 is left empty on success.
Parameters
| Name | Direction | Description |
|---|---|---|
l |
in,out | Destination list. |
l2 |
in,out | Source list. May be emptied on success. |
Success
Returns true. l->length grows by the previous l2->length; the appended nodes form the new tail of l. When l has no copy_init handler, the nodes from l2 have been relinked into l and l2 is left empty (head/tail NULL, length 0). With a deep-copy handler, l2 is unchanged.
Failure
Returns false on allocation failure. Both l and l2 are unchanged.
Usage example (Cross-references)
Usage examples (Cross-references)
static bool test_list_merge_l_preserves_source_hooks_for_reuse(void) {
WriteFmt("Testing ListMergeL preserves source hooks for reuse\n");
DefaultAllocator alloc = DefaultAllocatorInit(); ListPushBackR(&src, 3);
ListPushBackR(&src, 4);
ListMergeL(&dest, &src);
bool result = (g_copy_init_count == 2); ListPushBackR(&src_l, 3);
ListPushBackR(&src_l, 4);
ListMergeL(&dest_l, &src_l);
ListPushBackR(&dest_r, 1); ListPushBackR(&shallow_src, 11);
ListPushBackR(&shallow_src, 12);
ListMergeL(&deep_dest, &shallow_src);
ListMergeL(&empty_dest, &empty_src); ListPushBackR(&shallow_src, 12);
ListMergeL(&deep_dest, &shallow_src);
ListMergeL(&empty_dest, &empty_src);
bool result = (g_copy_init_count == 2);- In
Insert.h:277:
/// TAGS: List, Merge, Insert
///
#define ListMerge(l, l2) ListMergeL((l), (l2))
///
- In
Insert.h:503:
#define ListMustMergeL(l, l2) \
do { \
if (!ListMergeL((l), (l2))) { \
LOG_FATAL("ListMustMergeL failed"); \
} \
Last updated on