There's also a well-known one here, in klib: https://github.com/attractivechaos/klib/blob/master/kvec.h
There's also a well-known one here, in klib: https://github.com/attractivechaos/klib/blob/master/kvec.h
1. not using "do {} while (0)". This may lead to compile errors.
2. using uint32_t for capacity. On 64-bit machine, this doesn't save memory.
3. DYN_ARR_RESIZE() may have a quadratic time complexity if some is calling DYN_ARR_RESIZE(a, 10); DYN_ARR_RESIZE(a, 11); DYN_ARR_RESIZE(a, 12) etc in a loop. kv_resize() in kvec.h wouldn't have this problem.
4. Segfault if capacity is 0.
Part of the reason why C developers "feel" productive, but can't produce anything of meaningful complexity.
Anyway, I think this HN posting has this "crazy" flavor of using macros to simulate generics, and that's the specific kind of implementation that I meant, which klib also does.