A learning-oriented dynamic vector and linear allocator written in C.
- Dynamic heap-based integer storage
- Manual memory management
- Linear allocation strategy
- Dynamic expansion using realloc()
- Raw byte-level memory handling
- Simple vector push system
The vector internally stores:
base→ start address of allocated heap memoryused→ currently occupied bytescapacity→ total allocated bytes
Memory layout:
[used used used free free free]
Allocations move linearly forward using an offset.
.
├── main.c
├── utils.c
├── utils.h
Compile using gcc:
make # to compile and run normally
make fall # to compile and run but with more safety using sanitizersVector *ages = vector_init(3);
vector_push(ages, 10);
vector_push(ages, 14);
vector_push(ages, 18);- Integer-only support
- No automatic resize on push
- No pop/remove operations
- No alignment handling
- No bounds checking
- Generic type support
- Automatic resizing
- Arena allocator implementation
- Free-list allocator
- Memory debugging utilities
This project was built to understand:
- malloc()
- realloc()
- pointer arithmetic
- heap memory layout
- allocator design
- byte-level memory operations