Latest Tech News

Stay updated with the latest in technology, AI, cybersecurity, and more

Filtered by: vec_ptr Clear Filter

Generic Containers in C: Vec

Generic Containers in C: vec Martin Uecker, 2025-07-20 I discuss the implementation of type and bounds safe generic containers in C. Previously, I discussed a span type, and bounds checking using arrays. Here, I will discuss a vector type. A vector type is essentially a resizable array. A vector type could be used as in the following example. int main() { vec(int) *vec_ptr = calloc(1, sizeof *vec_ptr); if (!vec_ptr) // memory out abort(); for (int i = 0; i < 10; i++) vec_push(int, &vec