Implementing dynamically sized array in C