All Topics
All Topics
Technology
Technology
Design
Design
Programming
Programming
Science
Science
News
News
Gaming
Gaming
Entertainment
Entertainment
Business
Business
Finance
Finance
Sports
Sports
Health
Health
Food
Food
Travel
Travel
Art
Art
Music
Music
Books
Books
Education
Education
Politics
Politics
Personal
Personal
No algorithm. No AI slop. No ads. Just RSS. Pro-human. Indie writers. Real journalism. Open web. Chronological. Hand toasted.

Vec: A Minimal C Library for Generic Dynamic Arrays with O(1) Amortized Push Operations

By

Lucas_Marchetti

8mo ago· 7 min readenCode

Summary

Vec is a minimal C library that provides generic, contiguous dynamic arrays with O(1) amortized push operations. It offers a method-style API, geometric growth (doubling capacity), and defensive programming features including overflow guards, bounds-checked accessors, and well-defined behavior for various operations. The library emphasizes cache locality, SIMD-friendliness, and leak safety for C programming.

Key quotes

· 4 pulled
Vec is a generic, fast, leak‑safe dynamic array for C
It stores elements contiguously, grows geometrically (×2) for amortized O(1) push
The library is defensive by default: overflow guards before allocations, bounds‑checked accessors, and well‑defined behavior
Contiguous memory: better cache locality and prefetching than node‑based structures, fewer pointer indirections, great for iteration and SIMD‑friendly data
Snippet from the RSS feed
🌀 A minimal C library offering generic, contiguous dynamic arrays with O(1) amortized push. - L-A-Marchetti/Vec

You might also wanna read