Dynamic array implementation for C