Skip to content

StrMergeR

Description

Merge a copy of str2 into the end of str with R-value (read-only- source) semantics. The source is never emptied.

Success

Returns true; str grows by str2->length characters; str2 is untouched.

Failure

Returns false on allocation failure. Both strings unchanged.

Usage example (Cross-references)

Usage examples (Cross-references)
                if (n > 0) {
                    StrResize(&tmpbuf, (size)n);
                    StrMergeR(buf, &tmpbuf);
                    total_read += n;
                } else if (n == 0) {
    
                StrResize(&tmpbuf, bytes_read);
                StrMergeR(buf, &tmpbuf);
                total_read += bytes_read;
            }
                    break;
                StrResize(&chunk, (size)n);
                StrMergeR(out, &chunk);
            }
        }
    // Test StrMergeR function
    bool test_str_merge_r(void) {
        WriteFmt("Testing StrMergeR\n");
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        // Merge s2 into s1 (R-value semantics)
        StrMergeR(&s1, &s2);
    
        // Check that the strings were merged correctly
Last updated on