ZstrDupN
Description
Duplicates a string up to the specified length. Allocates a new buffer through alloc and copies at most n characters.
alloc is optional inside a Scope block (defaults to MisraScope).
Success
Returns a pointer to the newly allocated duplicate string.
Failure
Returns NULL if memory allocation fails.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Io.c:2887:
// the caller owns and may mutate the returned buffer. ZstrDupN's Zstr
// return is just the project-wide convention for fresh allocations.
result = (char *)ZstrDupN(StrBegin(&temp), StrLen(&temp), allocator_ptr);
if (!result) {
LOG_ERROR("Failed to allocate memory for string");
Last updated on