VecTryReduceSpace

Table of Contents

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

NameDirectionDescription
vin,outVector

Success

return

Failure

Does not return

Usage example (Cross-references)

    /// FAILURE : Does not return
    ///
    #define StrTryReduceSpace(str) VecTryReduceSpace(str)
    
    ///
    // Test VecTryReduceSpace function
    bool test_vec_try_reduce_space(void) {
    printf("Testing VecTryReduceSpace\n");
    
    // Create a vector of integers
    
    // Try to reduce space
    VecTryReduceSpace(&vec);
    
    // Capacity should now be closer to the actual length

Share :