I have a two-dimensional int
array allocated as follows:
int **matrix = (int**)malloc(x * sizeof(int));
for (i = 0; i < x; i++)
matrix[i] = (int*)malloc(y * sizeof(int));
If I do realloc
this array by the following code
int **matrix = (int**)realloc(matrix, x * sizeof(int));
for (i = 0; i < x; i++)
matrix[i] = (int*)malloc((y) * sizeof(int));
will there be any leftover "tails" of second dimension of the array and should I use free()
function for them before reallocating, or they will go away themselves?