StrMerge
- Macro
- August 22, 2025
Table of Contents
StrMerge
StrMerge
Description
Merge two strings and store the result in first string. By default, this uses R-value semantics (preserves source string). 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
This preserves the source string. If you want to transfer ownership and reset the source string, use StrMergeL instead.
Parameters
Name | Direction | Description |
---|---|---|
str | in,out | Str to insert array chars into. |
str2 | in | Str to be inserted. |
Success
str
Failure
NULL
Usage example (Cross-references)
- In
Io.c:804
:
}
StrPushBackZstr(o, "0x");
StrMerge(o, &hex);
StrDeinit(&hex);
});
- In
Io.c:874
:
}
StrPushBackZstr(o, "0x");
StrMerge(o, &hex);
StrDeinit(&hex);
i++;
- In
Io.c:951
:
// Merge the formatted number into output
StrMerge(o, &temp);
StrDeinit(&temp);
- In
Io.c:1043
:
// Merge the formatted number into output
StrMerge(o, &temp);
StrDeinit(&temp);
- In
Io.c:1153
:
// Merge the formatted number into output
StrMerge(o, &temp);
StrDeinit(&temp);
}
- In
Io.c:2268
:
} else {
Str bit_str = BitVecToStr(bv);
StrMerge(o, &bit_str);
StrDeinit(&bit_str);
}
- In
MisraDoc.c:132
:
// keep track of current path we're exploring
Str current_path = StrInit();
StrMerge(¤t_path, &dir_name);
SysDirContents dir_contents = SysGetDirContents(dir_name.data);
- In
MisraDoc.c:141
:
// create new directory path relative to current directory search path
Str path = StrInit();
StrMerge(&path, ¤t_path);
StrPushBack(&path, '/');
StrMerge(&path, &dir_entry.name);
- In
MisraDoc.c:143
:
StrMerge(&path, ¤t_path);
StrPushBack(&path, '/');
StrMerge(&path, &dir_entry.name);
// store the directory name, ownersip transferred
- In
MisraDoc.c:150
:
// create complete relative file path
Str path = StrInit();
StrMerge(&path, ¤t_path);
StrPushBack(&path, '/');
StrMerge(&path, &dir_entry.name);
- In
MisraDoc.c:152
:
StrMerge(&path, ¤t_path);
StrPushBack(&path, '/');
StrMerge(&path, &dir_entry.name);
// store discovered file name, ownersip transferred
- In
MisraDoc.c:179
:
Str output_path = StrInit();
Scope(&output_path, StrDeinit, {
StrMerge(&output_path, &file_path);
LOG_INFO("{}", output_path);
StrReplaceZstr(&output_path, "/", "-", -1);
- In
MisraDoc.c:202
:
StrWriteFmt(&md_code, mdHeader, output_path.data, output_path.data, output_path.data);
StrMerge(&md_code, &file_contents);
StrWriteFmt(&md_code, "\n```");
- In
Str.Insert.c:292
:
// Test StrMerge function (alias for StrMergeR)
bool test_str_merge(void) {
printf("Testing StrMerge\n");
Str s1 = StrInitFromZstr("Hello");
- In
Str.Insert.c:298
:
// Merge s2 into s1
StrMerge(&s1, &s2);
// Check that the strings were merged correctly