is it possible to realloc memory from a pointer to NULL in C?
int *v = 0;
for(i = 0; i < 10; i++)
v = (int *) realloc(v, (i+1)*sizeof(int));
If ptr is NULL, then the call is equivalent to malloc(size), for all values of size.
Source: man 3 realloc