VecPushBackL
- Macro
- August 22, 2025
Table of Contents
VecPushBackL
VecPushBackL
Description
Push an l-value into vector back.
Note
Ownership trasfer takes place if vector is not creating it’s own copy of item.
Parameters
Name | Direction | Description |
---|---|---|
v | in,out | Vector to push item into |
lval | in | l-value to be pushed back |
Success
return
Failure
Does not return
Usage example (Cross-references)
- In
Insert.h:640
:
/// FAILURE : Does not return
///
#define VecPushFront(v, val) VecPushBackL((v), (val))
///
- In
Vec.Insert.c:323
:
// Test L-value insert operations
int l_value = 100;
VecPushBackL(&vec, l_value);
// Check that the element was added
- In
Vec.Insert.c:400
:
// Test VecPushBackL
int val1 = 10;
VecPushBackL(&vec, val1);
bool result = (val1 == 0); // Should be memset to 0
// Add items to vectors
VecPushBackL(&vec3, item4);
VecPushBackL(&vec4, item5);
// Add items to vectors
VecPushBackL(&vec3, item4);
VecPushBackL(&vec4, item5);
// Check that item 4 and 5 are no longer valid
// Test VecPushBackL
int val1 = 10;
VecPushBackL(&vec, val1);
// Test VecPushFrontL
// Test VecPushBackL memset behavior with complex structures
bool test_lvalue_memset_pushback(void) {
printf("Testing VecPushBackL memset with complex structures\n");
// Create a test item
// Insert with L-value semantics (vector takes ownership)
VecPushBackL(&temp_vec, item);
// Check that the item was memset to 0
// Add the dummy item using L-value semantics
VecPushBackL(&vec, dummy);
// Now insert our test item at position 0 using L-value semantics
// Add the dummy items using L-value semantics
VecPushBackL(&vec, dummy1);
VecPushBackL(&vec, dummy2);
VecPushBackL(&vec, dummy3);
// Add the dummy items using L-value semantics
VecPushBackL(&vec, dummy1);
VecPushBackL(&vec, dummy2);
VecPushBackL(&vec, dummy3);
VecPushBackL(&vec, dummy1);
VecPushBackL(&vec, dummy2);
VecPushBackL(&vec, dummy3);
// Test 1: Insert at the beginning
ComplexItem dummy = {0};
dummy.name = ZstrDup("Dummy");
VecPushBackL(&vec, dummy);
// Insert with L-value semantics at the front (vector takes ownership)
// Add items to vec2
VecPushBackL(&vec2, item1);
VecPushBackL(&vec2, item2);
// Add items to vec2
VecPushBackL(&vec2, item1);
VecPushBackL(&vec2, item2);
// Verify items were cleared after being added to vec2