A fixed array cannot grow, so C programs keep a pointer to a heap block plus two counts: size, how many elements are in use, and capacity, how many fit before the block must grow. When size reaches capacity, realloc asks for a bigger block and copies the old elements into it.
Growing by doubling the capacity, rather than by one element, keeps the average cost of a push constant: copies happen rarely and get rarer as the array grows. This is what std::vector does in C++.
realloc returns NULL if it fails and leaves the old block untouched, so store its result in a temporary first; writing v->data = realloc(v->data, ...) loses the only pointer to the old block on failure.
Double the capacity, starting at 4, and keep the old block if realloc fails.