VecInit
Description
Initialize a Vec bound to an allocator. The argument may be either a typed allocator handle (&heap, &arena, …) or a raw Allocator * — ALLOCATOR_OF typechecks both at compile time and converts to Allocator * via a whole-pointer typecast.
Inside a Scope(...) block the allocator argument may be omitted; the macro then binds to the internal MisraScope allocator the scope provides. Outside a Scope, calling VecInit() with no argument fails to compile because MisraScope is undeclared - the safety net the design relies on.
Usage example (from documentation)
Scope(alloc, DefaultAllocator) {
Vec(int) v = VecInit(); // uses MisraScope
Vec(int) w = VecInit(alloc); // uses the named user-pool
...
VecDeinit(&v);
VecDeinit(&w);
}Usage example (Cross-references)
Usage examples (Cross-references)
- In
Buf.h:41:
/// TAGS: Buf, Init, Construct, Lifecycle
///
#define BufInit(...) VecInit(__VA_ARGS__)
///
- In
Str.c:258:
ValidateStr(s);
StrIters sv = (StrIters)VecInit(s->allocator);
Zstr prev = s->data;
Zstr end = s->data + s->length;- In
Str.c:292:
ValidateStr(s);
Strs sv = (Strs)VecInit(s->allocator);
sv.copy_deinit = (GenericCopyDeinit)str_deinit;
Zstr prev = s->data;- In
Dir.c:70:
}
DirContents dc = (DirContents)VecInit(alloc);
// Construct the search path: "<path>\*". Built with the in-tree
- In
Dir.c:198:
}
DirContents dc = (DirContents)VecInit(alloc);
// O_RDONLY | O_DIRECTORY | O_CLOEXEC. Values match between Linux
- In
Ops.c:42:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Ops.c:77:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Ops.c:129:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data in unsorted order
- In
Ops.c:169:
typedef Vec(u32) U32Vec;
U32Vec vec = VecInit(&alloc);
for (u32 i = 0; i < 3; i++) {
VecPushBackR(&vec, i);- In
Ops.c:194:
typedef Vec(u32) U32Vec;
U32Vec vec = VecInit(&alloc);
for (u32 i = 0; i < 3; i++) {
VecPushBackR(&vec, i);- In
Complex.c:391:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Test VecPushBackL
- In
Complex.c:439:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some initial elements
- In
Complex.c:474:
// Now test VecInsertRangeFastR in isolation
IntVec vec2 = VecInit(&alloc);
// Add some initial elements
- In
Complex.c:516:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some initial elements
- In
Complex.c:607:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Test pushing to empty vector
- In
Complex.c:907:
typedef Vec(int) IntVec;
IntVec src = VecInit(&local);
int values[] = {1, 2, 3};
for (int i = 0; i < 3; i++) {- In
Complex.c:913:
}
IntVec dst = VecInit(&local);
VecInitClone(&dst, &src);- In
Complex.c:933:
typedef Vec(int) IntVec;
IntVec src = VecInit(&local);
int values[] = {1, 2, 3};
for (int i = 0; i < 3; i++) {- In
Complex.c:939:
}
IntVec dst = VecInit(&local);
VecInitClone(&dst, &src);- In
Complex.c:959:
typedef Vec(int) IntVec;
IntVec src = VecInit(&local);
int values[] = {1, 2, 3};
for (int i = 0; i < 3; i++) {- In
Complex.c:965:
}
IntVec dst = VecInit(&local);
VecInitClone(&dst, &src);- In
Complex.c:984:
typedef Vec(int) IntVec;
IntVec src = VecInit(&local);
int values[] = {1, 2, 3};
for (int i = 0; i < 3; i++) {- In
Complex.c:990:
}
IntVec dst = VecInit(&local);
VecInitClone(&dst, &src);- In
Complex.c:1009:
typedef Vec(int) IntVec;
IntVec src = VecInit(&local);
int values[] = {1, 2, 3};
for (int i = 0; i < 3; i++) {- In
Complex.c:1015:
}
IntVec dst = VecInit(&local);
bool cloned = VecInitClone(&dst, &src);- In
Memory.c:88:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Reserve more space than needed
- In
Memory.c:128:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Memory.c:176:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Initial capacity should be 0
- In
Memory.c:223:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Memory.c:265:
typedef Vec(u32) U32Vec;
U32Vec vec = VecInit(&alloc);
u32 seed[] = {1, 2};- In
Memory.c:310:
typedef Vec(u64) U64Vec;
U64Vec vec = VecInit(&alloc);
u64 seed[] = {1, 2};- In
Memory.c:332:
typedef Vec(u32) U32Vec;
U32Vec vec = VecInit(&alloc);
u32 seed[] = {7, 8};- In
Memory.c:353:
typedef Vec(u32) U32Vec;
U32Vec vec = VecInit(&alloc);
// Empty -> grow branch -> reserve_pow2_vec(10). Real: next pow2 >= 10 == 16.
- In
Memory.c:378:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&heap);
// Capacity 8 -> 64-byte class (16 int slots). Poison the whole class slot.
- In
Memory.c:426:
typedef Vec(char) CharVec;
CharVec vec = VecInit(&heap);
// n + 1 == SIZE_MAX == (size)-1 / 1: the exact boundary. Real code does not
- In
Memory.c:487:
typedef Vec(char) CharVec;
CharVec vec = VecInit(&local);
// ~16 KiB of live chars: a 42x over-write spans ~688 KiB, far past the
- In
Memory.c:515:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&local);
vec.copy_deinit = (GenericCopyDeinit)clear_counting_deinit;- In
Memory.c:550:
} Wide; // sizeof == 64
typedef Vec(Wide) WideVec;
WideVec vec = VecInit(&local);
const u32 N = 60000;- In
Memory.c:580:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&local);
VecReserve(&vec, 64);- In
Memory.c:605:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&local);
VecReserve(&vec, 50); // length stays 0, capacity > 0, data != NULL
- In
Memory.c:626:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&local);
VecReserve(&vec, 50); // length stays 0
- In
Memory.c:647:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&local);
VecReserve(&vec, 100);- In
Memory.c:677:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&local);
int values[] = {10, 20, 30};- In
Memory.c:714:
} Big;
typedef Vec(Big) BigVec;
BigVec vec = VecInit(&alloc);
// (size)1<<43 * 2^21 == 2^64 -> wraps past `size`. Well under the
- In
Init.c:57:
// Test basic vector initialization
bool test_vec_init_basic(void) {
WriteFmt("Testing VecInit\n");
// Test with int type
- In
Init.c:61:
// Test with int type
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Check initial state
- In
Init.c:73:
// Test with struct type
typedef Vec(TestItem) TestVec;
TestVec test_vec = VecInit(&alloc);
// Check initial state
- In
Init.c:88:
// Test aligned vector initialization
bool test_vec_init_aligned(void) {
WriteFmt("Testing VecInit with aligned allocator\n");
HeapAllocator aligned4 = HeapAllocatorInitAligned(4);- In
Init.c:95:
// Test with int type and 4-byte alignment
typedef Vec(int) IntVec;
IntVec vec = VecInit(&aligned4);
// Check initial state
- In
Init.c:107:
// Test with struct type and 16-byte alignment
typedef Vec(TestItem) TestVec;
TestVec test_vec = VecInit(&aligned16);
// Check initial state
- In
Init.c:144:
// Test vector initialization with alignment and deep copy functions
bool test_vec_init_aligned_with_deep_copy(void) {
WriteFmt("Testing VecInit with aligned allocator and deep copy\n");
HeapAllocator aligned8 = HeapAllocatorInitAligned(8);- In
Init.c:167:
// Test vector initialization variants with an explicit optional allocator
bool test_vec_init_optional_allocator(void) {
WriteFmt("Testing VecInit optional allocator\n");
typedef Vec(TestItem) TestVec;- In
Init.c:186:
h64.base.retry_limit = 17;
TestVec vec_a = VecInit(&h_default);
TestVec vec_b = VecInitT(vec_b, &h_default);
TestVec vec_c = VecInitWithDeepCopy(TestItemCopyInit, TestItemDeinit, &h_default);- In
Init.c:190:
TestVec vec_c = VecInitWithDeepCopy(TestItemCopyInit, TestItemDeinit, &h_default);
TestVec vec_d = VecInitWithDeepCopyT(vec_d, TestItemCopyInit, TestItemDeinit, &h_default);
TestVec vec_e = VecInit(&h8);
TestVec vec_f = VecInitT(vec_f, &h16);
TestVec vec_g = VecInitWithDeepCopy(TestItemCopyInit, TestItemDeinit, &h32);- In
Init.c:298:
// Create a source vector
typedef Vec(int) IntVec;
IntVec src = VecInit(&alloc);
// Add some data
- In
Init.c:306:
// Create a destination vector
IntVec clone = VecInit(&alloc);
// Clone the source vector into the destination
- In
Init.c:341:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&local);
vec.copy_deinit = (GenericCopyDeinit)counting_deinit;- In
Insert.c:84:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Push some elements to the back
- In
Insert.c:112:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Push some elements to the front
- In
Insert.c:140:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Insert at index 0 (empty vector)
- In
Insert.c:175:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Push an array to the back
- In
Insert.c:216:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Push an array to the front of empty vector
- In
Insert.c:257:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Push some elements first
- In
Insert.c:290:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some initial elements
- In
Insert.c:297:
// Create another vector with elements to insert
IntVec src = VecInit(&alloc);
int src_values[] = {40, 50, 60};
VecPushBackArrR(&src, src_values, 3);- In
Insert.c:328:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec1 = VecInit(&alloc);
// Add some elements to first vector
- In
Insert.c:335:
// Create second vector
IntVec vec2 = VecInit(&alloc);
// Add some elements to second vector
- In
Insert.c:379:
local_heap.base.retry_limit = 11;
IntVec src = VecInit(&local_heap);
int values[] = {10, 20, 30};
VecPushBackArrR(&src, values, 3);- In
Insert.c:388:
// int[]. Stronger alignment is exercised separately - it's not what
// this test is asserting.
IntVec dst = VecInit(VecAllocator(&src));
// intentional bypass: testing hook propagation; no public VecSetCopyHooks mutator exists
dst.copy_init = src.copy_init;- In
Insert.c:414:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Test R-value insert operations
- In
Insert.c:497:
// Create a vector of integers without copy_init
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Test VecPushBackL
- In
Insert.c:547:
// Test VecMergeL
IntVec vec2 = VecInit(&alloc);
int merge_vals[] = {140, 150, 160};
for (int i = 0; i < 3; i++) {- In
Insert.c:577:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
int originals[] = {10, 20, 30, 40, 50, 60, 70, 80};- In
Insert.c:711:
WriteFmt("Testing fast-insert SIZE_MAX count returns false (no abort)\n");
ElemVec vec = VecInit(&alloc);
Elem src[1] = {- In
Insert.c:733:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
VecReserve(&vec, 8);- In
Insert.c:780:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
VecReserve(&vec, 10); // exact, non-power-of-2 capacity
- In
Insert.c:809:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
int add[8] = {10, 20, 30, 40, 50, 60, 70, 80};- In
Insert.c:833:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
int add[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};- In
Insert.c:858:
WriteFmt("Testing fast-insert preserves displaced tail (aligned_size)\n");
ElemVec vec = VecInit(&alloc); // no copy hooks: plain MemCopy path
Elem orig[4];- In
Insert.c:916:
WriteFmt("Testing fast-insert displacement move stays in bounds (over-copy)\n");
ElemVec vec = VecInit(&alloc); // no copy hooks: plain MemCopy path
// N live originals; inserting N at idx 0 makes displaced == min(N, N) == N,
- In
Insert.c:929:
// The inserted block is held in a scratch vec; its raw storage feeds the
// fast insert.
ElemVec ins = VecInit(&alloc);
for (size i = 0; i < N; i++) {
Elem e = {.value = 1000000 + (int)i, .live = false};- In
Insert.c:1416:
WriteFmt("Testing insert with count == SIZE_MAX returns false (no overflow)\n");
U64Vec vec = VecInit(&alloc);
u64 one = 1;- In
Insert.c:1431:
WriteFmt("Testing front insert preserves originals (aligned_size assign)\n");
U64Vec vec = VecInit(&alloc);
VecReserve(&vec, 16);
u64 originals[] = {10, 20, 30};- In
Insert.c:1450:
WriteFmt("Testing front insert keeps first original (aligned_size call)\n");
U64Vec vec = VecInit(&alloc);
VecReserve(&vec, 16);
u64 originals[] = {11, 22, 33};- In
Insert.c:1473:
// while the real single-element move stays in bounds.
const size N = 100000;
U64Vec vec = VecInit(&alloc);
for (size i = 0; i < N; i++) {
u64 v = (u64)i;- In
Insert.c:1742:
typedef Vec(u32) U32Vec;
U32Vec vec = VecInit(&local);
u32 items[] = {111u, 222u, 333u};- In
Insert.c:1762:
typedef Vec(u32) U32Vec;
U32Vec vec = VecInit(&local);
u32 items[] = {444u, 555u, 666u};- In
Insert.c:1784:
typedef Vec(u32) U32Vec;
U32Vec vec = VecInit(&local);
u32 val = 777u;- In
Type.c:27:
// Define a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Check initial state
- In
Type.c:39:
// Test with a struct type
typedef Vec(TestItem) TestVec;
TestVec test_vec = VecInit(&alloc);
// Check initial state
- In
Type.c:61:
// Create a valid vector
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// This should not abort
- In
Remove.c:122:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Remove.c:170:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Remove.c:218:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Remove.c:266:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Remove.c:303:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Remove.c:339:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Remove.c:415:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Remove.c:461:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Remove.c:497:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Remove.c:532:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Remove.c:613:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Remove.c:690:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Remove.c:727:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Remove.c:762:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Remove.c:841:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Remove.c:922:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
int values[] = {10, 20, 30};- In
Remove.c:944:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
int values[] = {10, 20, 30, 40};- In
Remove.c:966:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
int values[] = {11, 22, 33, 44};- In
Remove.c:1103:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
int values[] = {1, 2, 3, 4, 5};- In
Remove.c:1126:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
int values[] = {1, 2, 3, 4, 5};- In
Remove.c:1147:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
const int N = 100000;- In
Remove.c:1254:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
const int N = 40002;- In
Remove.c:1277:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
const int N = 40000;- In
Remove.c:1300:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
const int N = 40000;- In
Remove.c:1321:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
for (int i = 0; i < 10; i++) {
VecPushBackR(&vec, i); // [0..9]
- In
Remove.c:1340:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
for (int i = 0; i < 10; i++) {
VecPushBackR(&vec, i); // [0..9]
- In
Remove.c:1359:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
const int N = 40000;- In
Remove.c:1400:
typedef Vec(u64) U64Vec;
U64Vec vec = VecInit(&alloc);
// Large, tightly-allocated buffer: capacity == length so the only slack is
- In
Remove.c:1439:
typedef Vec(u64) U64Vec;
U64Vec vec = VecInit(&alloc);
const size N = 100000;- In
Foreach.c:36:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Foreach.c:75:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Foreach.c:111:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Foreach.c:152:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Foreach.c:183:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Foreach.c:216:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Foreach.c:243:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Foreach.c:277:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Foreach.c:311:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some elements
- In
Foreach.c:351:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some elements
- In
Foreach.c:389:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add several elements
- In
Foreach.c:428:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add several elements
- In
Foreach.c:466:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add several elements
- In
Foreach.c:503:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add several elements
- In
Foreach.c:541:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add several elements
- In
Access.c:36:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Access.c:71:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Access.c:111:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Access.c:145:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Add some data
- In
Access.c:179:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Check initial size and length
- In
Access.c:205:
// still `sizeof(int)`, so VecSize and VecAlignedOffsetAt agree.
typedef Vec(int) AlignedIntVec;
AlignedIntVec aligned_vec = VecInit(&aligned8);
// Add some data
- In
Access.c:235:
// Create a vector of integers with default alignment (1)
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
// Check offsets
- In
Access.c:248:
// alignment: the allocator governs only the buffer base, never the stride.
typedef Vec(int) AlignedIntVec;
AlignedIntVec aligned_vec = VecInit(&aligned8);
// Stride stays `sizeof(int)` even on an 8-byte-aligned allocator.
- In
Access.c:270:
typedef Vec(int) IntVec;
IntVec vec = VecInit(&alloc);
int needle = 20;- In
Access.c:304:
typedef Vec(u32) U32Vec;
U32Vec vec = VecInit(&alloc);
u32 values[] = {111, 222, 333, 444};- In
Access.c:332:
typedef Vec(u32) U32Vec;
U32Vec src = VecInit(&alloc);
u32 values[] = {10, 20, 30, 40};
for (int i = 0; i < 4; i++) {- In
Access.c:338:
}
U32Vec dst = VecInit(&alloc);
VecInitClone(&dst, &src);- In
Arena.c:74:
ArenaAllocator arena = ArenaAllocatorInit();
typedef Vec(int) IntVec;
IntVec v = VecInit(&arena);
bool ok = true;- In
Page.c:71:
PageAllocator alloc = PageAllocatorInit();
typedef Vec(int) IntVec;
IntVec v = VecInit(&alloc);
bool ok = true;- In
Type.c:106:
// Create a valid Strs
Strs sv = VecInit(&alloc);
// This should not crash
- In
Type.c:156:
// Create an invalid Strs by corrupting its fields
Strs sv = VecInit(&alloc);
// Corrupt the vector to make it invalid
Str json = StrInit(&alloc);
Vec(i32) empty_numbers = VecInit(&alloc);
Vec(Str) empty_strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc); Str json = StrInit(&alloc);
Vec(i32) empty_list = VecInit(&alloc);
JW_OBJ(json, { Str json = StrInit(&alloc);
Vec(i32) empty_arr = VecInit(&alloc);
Vec(i32) filled_arr = VecInit(&alloc);
i32 val1 = 1, val2 = 2;
Vec(i32) empty_arr = VecInit(&alloc);
Vec(i32) filled_arr = VecInit(&alloc);
i32 val1 = 1, val2 = 2;
VecPushBack(&filled_arr, val1); Str json = StrInit(&alloc);
Vec(u32) numbers = VecInit(&alloc);
u32 num1 = 1, num2 = 2, num3 = 3;
VecPushBack(&numbers, num1); VecPushBack(&strings, str3);
Vec(bool) booleans = VecInit(&alloc);
bool bool1 = true, bool2 = false, bool3 = true;
VecPushBack(&booleans, bool1); StrIter si1 = StrIterFromStr(json1);
Vec(i32) items = VecInit(&alloc);
JR_OBJ(si1, { i32 x_value;
Vec(i32) filled_items;
} obj = {0, VecInit(&alloc)};
JR_OBJ(si, {- In
RoundTrip.c:369:
// Original data
Vec(i32) original_numbers = VecInit(&alloc);
Vec(Str) original_strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);- In
RoundTrip.c:397:
// Read back from JSON
Vec(i32) parsed_numbers = VecInit(&alloc);
Vec(Str) parsed_strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);- In
RoundTrip.c:674:
// Original empty data
Vec(i32) empty_numbers = VecInit(&alloc);
Vec(Str) empty_strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
Str empty_str = StrInit(&alloc);- In
RoundTrip.c:694:
// Read back from JSON
Vec(i32) parsed_numbers = VecInit(&alloc);
Vec(Str) parsed_strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
Str parsed_str = StrInit(&alloc);
Last updated on