Skip to content

ListMergeR

Description

Append a copy of all elements of l2 to the end of l. R-value form: the source list is never emptied; its contents are read-only.

Success

Returns true. l->length grows by l2->length; copies of every l2 node form the new tail of l. l2 is untouched.

Failure

Returns false on allocation failure. l is unchanged.

Usage example (Cross-references)

Usage examples (Cross-references)
    #define ListMustMergeR(l, l2)                                                                                          \
        do {                                                                                                               \
            if (!ListMergeR((l), (l2))) {                                                                                  \
                LOG_FATAL("ListMustMergeR failed");                                                                        \
            }                                                                                                              \
                }
    
                ListMergeR(list, &temp);
                ListDeinit(&temp); // Clean up temp to prevent memory leak
                break;
        s_copy_fail_at = s_copy_calls + 1;
    
        bool returned = ListMergeR(&dst, &src);
    
        bool result = (returned == false);
        ListPushBackR(&src_r, 3);
        ListPushBackR(&src_r, 4);
        ListMergeR(&dest_r, &src_r);
    
        ListPushBackR(&dest_a, 5);
Last updated on