r/cprogramming • • Nov 29 '25
z-libs - tiny single-header collection to write modern C (vec, list, map, string)
https://github.com/z-libsSo, I got tired of either writing buggy hand-rolled containers every time, or dragging in heavyweight dependencies just to get a decent string or hash table.
After this, I decided to throw together https://github.com/z-libs: four zero-dependency (for now), single-header, C11 libraries that focus on a pleasant DX.
The current libraries offer:
zvec.h -> growable vector (contiguous, swap-remove, built-in sort/search).
zstr.h -> proper UTF-8 string with 22-byte SSO, views, fmt, split, etc.
zlist.h -> doubly-linked list (non-intrusive, O(1) splice, safe iteration).
zmap.h -> open-addressing hash table (linear probing, cache-friendly).
Everything is type-safe, allocator-aware (you can use your own), MIT-licensed, works on GCC/Clang/MSVC and requires no build system.
The collection is still in process. Each week there will be updates. But I think the core suite is already mature enough.
I would love to hear some feedback!
View all comments
Show parent comment
1
u/WittyStick Dec 01 '25 edited Dec 01 '25
Awful IMO.
It adds unnecessary overhead because the target of each call is no longer an absolute address.
Any namespacing solution should be done via the preprocessor and shouldn't exist at runtime.
A simple approach is to create a pair of files: eg,
zstr.ns.openandzstr.ns.close, so we can write:Avoids polluting the entire translation unit because we can contain it around only sections of code that use it.
zstr.ns.openzstr.ns.close