Discussion about this post

User's avatar
kynsy's avatar

You could have the allocator provide a realloc function so you dont have to handle the realloc logic in `array_ensure_capacity`. Would make it easy to provide the C stdlib realloc function instead of handling the logic here. All that logic could be boiled down to just this:

const size_t new_size = sizeof(ListPrelude) + new_capacity * item_size;

prelude = prelude->allocator->realloc(prelude, new_size);

Expand full comment
Spyro's avatar

Extreme novice c programmer here:

This article has been very educational thus far on how one could manage dynamic arrays in c.

Thank you for posting this! I will be following your content <3

Expand full comment
8 more comments...

No posts