StrMergeR

Table of Contents

StrMergeR

Description

Merge two strings and store the result in first string, with R-value semantics. Data is copied from str2 into str. If a copy_init method is provided in str, each element from str2 will be copied using that method. Otherwise, a raw memory copy is performed.

Note

Unlike StrMergeL, this does NOT zero out the source string’s data after merging.

Parameters

NameDirectionDescription
strin,outStr to insert array chars into.
str2inStr to be inserted.

Success

str

Failure

NULL

Usage example (Cross-references)

    /// FAILURE : NULL
    ///
    #define StrMerge(str, str2) StrMergeR((str), (str2))
    
    ///
    // Test StrMergeR function
    bool test_str_merge_r(void) {
    printf("Testing StrMergeR\n");
    
    Str s1 = StrInitFromZstr("Hello");
    
    // Merge s2 into s1 (R-value semantics)
    StrMergeR(&s1, &s2);
    
    // Check that the strings were merged correctly

Share :