StrDup
Description
Clone a Str, inheriting the source allocator configuration.
Parameters
| Name | Direction | Description |
|---|---|---|
str |
in | Source string. |
Success
Returns a fully initialized Str that is a deep copy of str, inheriting its allocator binding. Same state effects as StrInitFromStr(str).
Failure
Returns an empty Str (length 0, capacity 0, data NULL, allocator bound) when allocation fails.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Str.c:82:
case STR_DUP : {
if (VecLen(str) > 0) {
Str temp = StrDup(str);
StrDeinit(str);
*str = temp;- In
Str.Init.c:111:
// Test StrDup function (alias for StrInitFromStr)
bool test_str_dup(void) {
WriteFmt("Testing StrDup\n");
Str src = StrInitFromZstr("Hello, World!");- In
Str.Init.c:114:
Str src = StrInitFromZstr("Hello, World!");
Str dst = StrDup(&src);
// Validate both strings
Last updated on