StrTryReduceSpace
Description
Shrink the string’s allocated capacity back to its current length. Use when previous growth left a large unused tail. See VecTryReduceSpace for the full SUCCESS/FAILURE contract.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Str.Memory.c:19:
// Test StrTryReduceSpace function
bool test_str_try_reduce_space(void) {
WriteFmt("Testing StrTryReduceSpace\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Str.Memory.c:35:
// Try to reduce space
StrTryReduceSpace(&s);
// Capacity should now be closer to the actual length
Last updated on