VecClear
Description
Set the vector length to 0 while keeping the allocated capacity. Element payloads are deinitialized via the configured copy_deinit handler when present.
Parameters
| Name | Direction | Description |
|---|---|---|
v |
in,out | Vector handle. |
Success
Returns to the caller. The vector length is now 0; the allocated capacity and data buffer are preserved. When copy_deinit is configured it has been invoked on each previously-stored element.
Failure
Function cannot fail.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Io.c:1059:
LOG_FATAL("buf_write_fmt: NULL out or fmtstr");
}
VecClear(out);
return render_binary_fmt((Str *)out, fmtstr, argv, argc);
}- In
VecCharPtr.c:156:
case VEC_CHAR_PTR_CLEAR : {
// VecClear automatically calls char_ptr_deinit on each element
VecClear(vec);
break;
}- In
VecStr.c:178:
case VEC_STR_CLEAR : {
// VecClear automatically calls StrDeinit on each element
VecClear(vec);
break;
}- In
VecInt.c:124:
// Memory operations
case VEC_INT_CLEAR : {
VecClear(vec);
break;
}- In
Vec.Ops.c:97:
// Test with a vector of even length
VecClear(&vec);
int even_values[] = {10, 20, 30, 40};
for (int i = 0; i < 4; i++) {- In
Vec.Memory.c:152:
// Test VecClear function
bool test_vec_clear(void) {
WriteFmt("Testing VecClear\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Vec.Memory.c:173:
// Clear the vector
VecClear(&vec);
// Length should now be 0
- In
Buf.h:62:
/// TAGS: Buf, Clear, Reuse
///
#define BufClear(b) VecClear(b)
// Read-only accessors. The leading `((void)0, ...)` makes each macro a
- In
Memory.h:87:
/// TAGS: Str, Memory, Clear
///
#define StrClear(str) VecClear(str)
///
Last updated on