VecTryReduceSpace
- Macro
- August 22, 2025
Table of Contents
VecTryReduceSpace
VecTryReduceSpace
Description
Try reducing memory footprint of vector. This is to be used when we know actual allocated memory for vec is large, and we won’t need it in future, so we can reduce it to whatever’s required at the moment.
Parameters
Name | Direction | Description |
---|---|---|
v | in,out | Vector |
Success
return
Failure
Does not return
Usage example (Cross-references)
- In
Memory.h:27
:
/// FAILURE : Does not return
///
#define StrTryReduceSpace(str) VecTryReduceSpace(str)
///
- In
Vec.Memory.c:17
:
// Test VecTryReduceSpace function
bool test_vec_try_reduce_space(void) {
printf("Testing VecTryReduceSpace\n");
// Create a vector of integers
- In
Vec.Memory.c:36
:
// Try to reduce space
VecTryReduceSpace(&vec);
// Capacity should now be closer to the actual length