Vec
- Macro
- August 22, 2025
Table of Contents
Vec
Vec
Description
Typesafe vector definition. This is much like C++ template std::vector
Note
Using this directly like Vec(T)
won’t always work, because each time this is used it defines a new type, and two Vec(T)
s are different from each other. To deal with this, you must typedef vector for a specific type. Throughout the code, any time that is in plural form is generally a vector. Like Strs
is a typedef of Vec(Str)
.
Usage example (from documentation)
Vec(int) integers; // Vector of integers
Vec(CustomStruct) my_data; // Vector of CustomStruct
Vec(float) real_numbers; // Vector of float values
Vec(const char*) names; Vector of c-style null-terminated strings
FIELDS:
- length : Number of items currently in vector (always <= capacity)
- capacity : Max number of items this vector can hold before doing a resize.
- copy_init : If provided then is used to create owned copies of items into vector.
- copy_deinit : If provided then is used to deinit data held by vector.
Caution when dealing with shared ownership.
- data : Data held by vector. Don't access by direct indexing. Use `VecAt(..)`
- alignment : Alignment requirement for each item in vector.
Usage example (Cross-references)
- In
Sys.h:93
:
/// TAGS: System, Directory, Container
///
typedef Vec(SysDirEntry) SysDirContents;
///
- In
Container.h:17
:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Container/BitVec.h>
- In
StrIter.h:4
:
#define MISRA_STD_UTILITY_STR_ITER_H
#include <Misra/Std/Container/Vec/Type.h>
#include <Misra/Std/Utility/Iter.h>
#include <Misra/Types.h>
- In
StrIter.h:9
:
typedef Iter(char) StrIter;
typedef Vec(StrIter) StrIters;
///
- In
Vec.h:11
:
// clang-format off
#include "Vec/Type.h"
#include "Vec/Init.h"
#include "Vec/Insert.h"
- In
Vec.h:12
:
// clang-format off
#include "Vec/Type.h"
#include "Vec/Init.h"
#include "Vec/Insert.h"
#include "Vec/Remove.h"
- In
Vec.h:13
:
#include "Vec/Type.h"
#include "Vec/Init.h"
#include "Vec/Insert.h"
#include "Vec/Remove.h"
#include "Vec/Access.h"
- In
Vec.h:14
:
#include "Vec/Init.h"
#include "Vec/Insert.h"
#include "Vec/Remove.h"
#include "Vec/Access.h"
#include "Vec/Memory.h"
- In
Vec.h:15
:
#include "Vec/Insert.h"
#include "Vec/Remove.h"
#include "Vec/Access.h"
#include "Vec/Memory.h"
#include "Vec/Foreach.h"
- In
Vec.h:16
:
#include "Vec/Remove.h"
#include "Vec/Access.h"
#include "Vec/Memory.h"
#include "Vec/Foreach.h"
#include "Vec/Ops.h"
- In
Vec.h:17
:
#include "Vec/Access.h"
#include "Vec/Memory.h"
#include "Vec/Foreach.h"
#include "Vec/Ops.h"
#include "Vec/Private.h"
- In
Vec.h:18
:
#include "Vec/Memory.h"
#include "Vec/Foreach.h"
#include "Vec/Ops.h"
#include "Vec/Private.h"
// clang-format on
- In
Vec.h:19
:
#include "Vec/Foreach.h"
#include "Vec/Ops.h"
#include "Vec/Private.h"
// clang-format on
- In
Type.h:11
:
#include <string.h>
#include <Misra/Std/Container/Vec/Type.h>
#include <Misra/Std/Utility/Iter/Type.h>
#include <Misra/Types.h>
- In
Type.h:18
:
/// The Str type is a specialization of Vec for characters
///
typedef Vec(char) Str;
///
- In
Type.h:23
:
/// Vector of strings
///
typedef Vec(Str) Strs;
///
- In
Type.h:12
:
#include <Misra/Std/Container/Common.h>
#include <Misra/Types.h>
#include <Misra/Std/Container/Vec.h>
///
- In
Type.h:39
:
} BitVec;
typedef Vec(BitVec) BitVecs;
///
- In
Vec.c:9
:
// ct
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Log.h>
#include <Misra/Sys.h>
- In
MisraEnum.c:33
:
} EnumEntry;
typedef Vec(EnumEntry) EnumEntries;
int main(int argc, char** argv) {
- In
MisraDoc.c:194
:
"date: 2025-05-12T05:00:00Z\n"
"# image: \"/images/image-placeholder.png\"\n"
"categories: [\"Vec\", \"Macro\", \"Generic\"]\n"
"author: \"Siddharth Mishra\"\n"
"tags: [\"vec\", \"macro\", \"generic\"]\n"
Str name;
f64 price;
Vec(Str) tags;
} SimpleProduct;
Str json = StrInit();
Vec(Str) languages = VecInitWithDeepCopy(NULL, StrDeinit);
// Create strings and push them properly
- In
Read.Simple.c:30
:
Str name;
f64 price;
Vec(Str) tags;
} SimpleProduct;
StrIter si = StrIterFromStr(json);
Vec(Str) languages = VecInitWithDeepCopy(NULL, StrDeinit);
JR_OBJ(si, {
Str json = StrInit();
Vec(i32) empty_numbers = VecInit();
Vec(Str) empty_strings = VecInitWithDeepCopy(NULL, StrDeinit);
Vec(i32) empty_numbers = VecInit();
Vec(Str) empty_strings = VecInitWithDeepCopy(NULL, StrDeinit);
JW_OBJ(json, {
Str json = StrInit();
Vec(i32) empty_list = VecInit();
JW_OBJ(json, {
Str json = StrInit();
Vec(i32) empty_arr = VecInit();
Vec(i32) filled_arr = VecInit();
i32 val1 = 1, val2 = 2;
Vec(i32) empty_arr = VecInit();
Vec(i32) filled_arr = VecInit();
i32 val1 = 1, val2 = 2;
VecPushBack(&filled_arr, val1);
f64 small_float;
bool is_valid;
Vec(Str) empty_array;
Vec(i64) numbers;
} EdgeCaseData;
bool is_valid;
Vec(Str) empty_array;
Vec(i64) numbers;
} EdgeCaseData;
StrIter si1 = StrIterFromStr(json1);
Vec(i32) items = VecInit();
JR_OBJ(si1, {
StrIter si2 = StrIterFromStr(json2);
Vec(Str) data = VecInitWithDeepCopy(NULL, StrDeinit);
JR_OBJ(si2, {
struct {
i32 x_value;
Vec(i32) filled_items;
} obj = {0, VecInit()};
} AnnSymbol;
typedef Vec(AnnSymbol) AnnSymbols;
typedef struct ApiResponse {
u64 analysis_id;
Str sha256;
Vec(Str) tags;
Str created_at;
u64 model_id;
Str json = StrInit();
Vec(FunctionInfo) functions = VecInitWithDeepCopy(NULL, FunctionInfoDeinit);
FunctionInfo func1 = {12345, StrInitFromZstr("test_func"), 1024, 4096};
Str json = StrInit();
Vec(AnnSymbol) symbols = VecInitWithDeepCopy(NULL, AnnSymbolDeinit);
AnnSymbol sym1 = {0};
Str json = StrInit();
Vec(u32) numbers = VecInit();
u32 num1 = 1, num2 = 2, num3 = 3;
VecPushBack(&numbers, num1);
VecPushBack(&numbers, num3);
Vec(Str) strings = VecInitWithDeepCopy(NULL, StrDeinit);
// Create strings and push them properly
VecPushBack(&strings, str3);
Vec(bool) booleans = VecInit();
bool bool1 = true, bool2 = false, bool3 = true;
VecPushBack(&booleans, bool1);
- In
RoundTrip.c:25
:
u32 timeout;
Str log_level;
Vec(Str) features;
} TestConfig;
- In
RoundTrip.c:31
:
TestPerson user;
TestConfig config;
Vec(i32) numbers;
Vec(bool) flags;
} ComplexData;
- In
RoundTrip.c:32
:
TestConfig config;
Vec(i32) numbers;
Vec(bool) flags;
} ComplexData;
- In
RoundTrip.c:352
:
// Original data
Vec(i32) original_numbers = VecInit();
Vec(Str) original_strings = VecInitWithDeepCopy(NULL, StrDeinit);
- In
RoundTrip.c:353
:
// Original data
Vec(i32) original_numbers = VecInit();
Vec(Str) original_strings = VecInitWithDeepCopy(NULL, StrDeinit);
// Populate arrays
- In
RoundTrip.c:380
:
// Read back from JSON
Vec(i32) parsed_numbers = VecInit();
Vec(Str) parsed_strings = VecInitWithDeepCopy(NULL, StrDeinit);
- In
RoundTrip.c:381
:
// Read back from JSON
Vec(i32) parsed_numbers = VecInit();
Vec(Str) parsed_strings = VecInitWithDeepCopy(NULL, StrDeinit);
StrIter si = StrIterFromStr(json);
- In
RoundTrip.c:648
:
// Original empty data
Vec(i32) empty_numbers = VecInit();
Vec(Str) empty_strings = VecInitWithDeepCopy(NULL, StrDeinit);
Str empty_str = StrInit();
- In
RoundTrip.c:649
:
// Original empty data
Vec(i32) empty_numbers = VecInit();
Vec(Str) empty_strings = VecInitWithDeepCopy(NULL, StrDeinit);
Str empty_str = StrInit();
- In
RoundTrip.c:668
:
// Read back from JSON
Vec(i32) parsed_numbers = VecInit();
Vec(Str) parsed_strings = VecInitWithDeepCopy(NULL, StrDeinit);
Str parsed_str = StrInit();
- In
RoundTrip.c:669
:
// Read back from JSON
Vec(i32) parsed_numbers = VecInit();
Vec(Str) parsed_strings = VecInitWithDeepCopy(NULL, StrDeinit);
Str parsed_str = StrInit();
bool found_empty_object = false;
- In
Read.Nested.c:25
:
} AnnSymbol;
typedef Vec(AnnSymbol) AnnSymbols;
typedef struct ApiResponse {
- In
Read.Nested.c:48
:
} FunctionInfo;
typedef Vec(FunctionInfo) FunctionInfos;
typedef struct ModelInfo {
- In
Read.Nested.c:55
:
} ModelInfo;
typedef Vec(ModelInfo) ModelInfos;
typedef struct SearchResult {
- In
Read.Nested.c:62
:
u64 analysis_id;
Str sha256;
Vec(Str) tags;
Str created_at;
u64 model_id;
- In
Read.Nested.c:69
:
} SearchResult;
typedef Vec(SearchResult) SearchResults;
void FunctionInfoDeinit(FunctionInfo* info) {
StrIter si = StrIterFromStr(json);
typedef Vec(AnnSymbol) Symbols;
Symbols symbols = VecInitWithDeepCopy(NULL, AnnSymbolDeinit);
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Log.h>
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
// Main function that runs all tests
int main(void) {
printf("[INFO] Starting Vec.Foreach.Simple tests\n\n");
// Array of normal test functions
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, NULL, 0, "Vec.Foreach.Simple");
}
- In
Vec.Access.c:1
:
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Log.h>
#include <stdio.h>
- In
Vec.Access.c:22
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Access.c:54
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Access.c:91
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Access.c:122
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Access.c:152
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Access.c:177
:
// Test with a vector with alignment > 1
typedef Vec(int) AlignedIntVec;
AlignedIntVec aligned_vec = VecInitAligned(8);
- In
Vec.Access.c:202
:
// Create a vector of integers with default alignment (1)
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Access.c:214
:
// Create a vector with 8-byte alignment
typedef Vec(int) AlignedIntVec;
AlignedIntVec aligned_vec = VecInitAligned(8);
- In
Vec.Access.c:233
:
// Main function that runs all tests
int main(void) {
printf("[INFO] Starting Vec.Access tests\n\n");
// Array of test functions
- In
Vec.Access.c:248
:
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, NULL, 0, "Vec.Access");
}
- In
Vec.Insert.c:1
:
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Log.h>
#include <stdio.h>
- In
Vec.Insert.c:27
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Insert.c:55
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Insert.c:83
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Insert.c:118
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Insert.c:159
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Insert.c:200
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Insert.c:233
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Insert.c:271
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec1 = VecInit();
- In
Vec.Insert.c:312
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Insert.c:395
:
// Create a vector of integers without copy_init
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Insert.c:468
:
// Main function that runs all tests
int main(void) {
printf("[INFO] Starting Vec.Insert tests\n\n");
// Array of test functions
- In
Vec.Insert.c:487
:
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, NULL, 0, "Vec.Insert");
}
- In
Vec.Type.c:1
:
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Log.h>
#include <stdio.h>
- In
Vec.Type.c:21
:
// Test basic Vec type functionality
bool test_vec_type_basic(void) {
printf("Testing basic Vec type functionality\n");
// Define a vector of integers
- In
Vec.Type.c:24
:
// Define a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Type.c:36
:
// Test with a struct type
typedef Vec(TestItem) TestVec;
TestVec test_vec = VecInit();
- In
Vec.Type.c:54
:
// Create a valid vector
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Type.c:71
:
// Main function that runs all tests
int main(void) {
printf("[INFO] Starting Vec.Type tests\n\n");
// Array of test functions
- In
Vec.Type.c:79
:
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, NULL, 0, "Vec.Type");
}
- In
Vec.Memory.c:1
:
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Log.h>
#include <stdio.h>
- In
Vec.Memory.c:20
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Memory.c:57
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Memory.c:102
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Memory.c:146
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Memory.c:181
:
// Main function that runs all tests
int main(void) {
printf("[INFO] Starting Vec.Memory tests\n\n");
// Array of test functions
- In
Vec.Memory.c:189
:
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, NULL, 0, "Vec.Memory");
}
- In
Vec.Complex.c:1
:
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Memory.h>
#include <Misra/Std/Log.h>
// Create a vector of ComplexItem with deep copy functions
typedef Vec(ComplexItem) ComplexVec;
ComplexVec vec = VecInitWithDeepCopy(ComplexItemCopyInit, ComplexItemDeinit);
// Create a vector of ComplexItem with deep copy functions
typedef Vec(ComplexItem) ComplexVec;
ComplexVec vec = VecInitWithDeepCopy(ComplexItemCopyInit, ComplexItemDeinit);
// Create a vector of ComplexItem with deep copy functions
typedef Vec(ComplexItem) ComplexVec;
ComplexVec vec = VecInitWithDeepCopy(ComplexItemCopyInit, ComplexItemDeinit);
// Create two vectors of ComplexItem with deep copy functions
typedef Vec(ComplexItem) ComplexVec;
ComplexVec vec1 = VecInitWithDeepCopy(ComplexItemCopyInit, ComplexItemDeinit);
ComplexVec vec2 = VecInitWithDeepCopy(ComplexItemCopyInit, ComplexItemDeinit);
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
// Create a temporary vector with no copy_init but with copy_deinit for proper cleanup
typedef Vec(ComplexItem) ComplexVec;
ComplexVec temp_vec = VecInitWithDeepCopy(NULL, ComplexItemDeinit);
// Create a vector with no copy_init but with copy_deinit for proper cleanup
typedef Vec(ComplexItem) ComplexVec;
ComplexVec vec = VecInitWithDeepCopy(NULL, ComplexItemDeinit);
// Create a vector with no copy_init but with copy_deinit for proper cleanup
typedef Vec(ComplexItem) ComplexVec;
ComplexVec vec = VecInitWithDeepCopy(NULL, ComplexItemDeinit);
// Create a vector with no copy_init but with copy_deinit for proper cleanup
typedef Vec(ComplexItem) ComplexVec;
ComplexVec vec = VecInitWithDeepCopy(NULL, ComplexItemDeinit);
// Create a vector with no copy_init but with copy_deinit for proper cleanup
typedef Vec(ComplexItem) ComplexVec;
ComplexVec vec1 = VecInitWithDeepCopy(NULL, ComplexItemDeinit);
ComplexVec vec2 = VecInitWithDeepCopy(NULL, ComplexItemDeinit);
// Create a vector with no copy_init but with copy_deinit for proper cleanup
typedef Vec(ComplexItem) ComplexVec;
ComplexVec vec = VecInitWithDeepCopy(NULL, ComplexItemDeinit);
// Main function that runs all tests
int main(void) {
printf("[INFO] Starting Vec.Complex tests\n\n");
// Array of test functions
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, NULL, 0, "Vec.Complex");
}
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Log.h>
printf("Testing VecForeach where modification causes out of bounds access (should crash)\n");
typedef Vec(int) IntVec;
IntVec vec = VecInit();
printf("Testing VecForeachIdx where idx goes out of bounds (should crash)\n");
typedef Vec(int) IntVec;
IntVec vec = VecInit();
printf("Testing VecForeachReverseIdx where idx goes out of bounds (should crash)\n");
typedef Vec(int) IntVec;
IntVec vec = VecInit();
printf("Testing VecForeachPtrIdx where idx goes out of bounds (should crash)\n");
typedef Vec(int) IntVec;
IntVec vec = VecInit();
printf("Testing VecForeachPtrReverseIdx where idx goes out of bounds (should crash)\n");
typedef Vec(int) IntVec;
IntVec vec = VecInit();
printf("Testing VecForeachPtrInRangeIdx where idx goes out of bounds (should crash)\n");
typedef Vec(int) IntVec;
IntVec vec = VecInit();
printf("Testing basic VecForeachIdx where idx goes out of bounds (should crash)\n");
typedef Vec(int) IntVec;
IntVec vec = VecInit();
// Main function that runs all deadend tests
int main(void) {
printf("[INFO] Starting Vec.Foreach.Deadend tests\n\n");
// Array of deadend test functions (tests that should crash)
// Run all deadend tests using the centralized test driver
return run_test_suite(NULL, 0, deadend_tests, deadend_count, "Vec.Foreach.Deadend");
}
- In
Vec.Remove.c:1
:
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Log.h>
- In
Vec.Remove.c:32
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Remove.c:80
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Remove.c:128
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Remove.c:176
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Remove.c:213
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Remove.c:249
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Remove.c:325
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Remove.c:371
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Remove.c:407
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Remove.c:442
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Remove.c:518
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Remove.c:595
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Remove.c:632
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Remove.c:667
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Remove.c:746
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Remove.c:842
:
// Use centralized test driver (no more argc/argv needed)
return run_test_suite(normal_tests, normal_count, NULL, 0, "Vec.Remove");
}
- In
Vec.Init.c:1
:
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Log.h>
- In
Vec.Init.c:46
:
// Test with int type
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Init.c:58
:
// Test with struct type
typedef Vec(TestItem) TestVec;
TestVec test_vec = VecInit();
- In
Vec.Init.c:76
:
// Test with int type and 4-byte alignment
typedef Vec(int) IntVec;
IntVec vec = VecInitAligned(4);
- In
Vec.Init.c:88
:
// Test with struct type and 16-byte alignment
typedef Vec(TestItem) TestVec;
TestVec test_vec = VecInitAligned(16);
- In
Vec.Init.c:106
:
// Test with struct type and custom copy/deinit functions
typedef Vec(TestItem) TestVec;
TestVec vec = VecInitWithDeepCopy(TestItemCopyInit, TestItemDeinit);
- In
Vec.Init.c:125
:
// Test with struct type, custom copy/deinit functions, and 8-byte alignment
typedef Vec(TestItem) TestVec;
TestVec vec = VecInitAlignedWithDeepCopy(TestItemCopyInit, TestItemDeinit, 8);
- In
Vec.Init.c:146
:
// Test with basic int type
typedef Vec(int) IntVec;
IntVec vec;
- In
Vec.Init.c:177
:
// Test with struct type
typedef Vec(TestItem) TestVec;
TestVec test_vec;
- In
Vec.Init.c:216
:
// Create a source vector
typedef Vec(int) IntVec;
IntVec src = VecInit();
- In
Vec.Init.c:254
:
// Main function that runs all tests
int main(void) {
printf("[INFO] Starting Vec.Init tests\n\n");
// Array of test functions
- In
Vec.Init.c:269
:
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, NULL, 0, "Vec.Init");
}
- In
Vec.Ops.c:1
:
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Log.h>
#include <stdio.h>
- In
Vec.Ops.c:33
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Ops.c:68
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Ops.c:120
:
// Create a vector of integers
typedef Vec(int) IntVec;
IntVec vec = VecInit();
- In
Vec.Ops.c:156
:
// Main function that runs all tests
int main(void) {
printf("[INFO] Starting Vec.Ops tests\n\n");
// Array of test functions
- In
Vec.Ops.c:164
:
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, NULL, 0, "Vec.Ops");
}