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)

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

Share :