I'm looking to realloc a double char array without free string in it, here is my code :
char **rea_scd_array(char **src, int add)
{
char **ret;
int i;
i = 0;
while (src[i] != '\0')
i++;
ret = (char**) malloc(sizeof(char*) * (i + add + 1));
ret[i + add] = '\0';
while (i >= 0)
{
ret[i] = &src[i][0];
i--;
}
free(&src);
return (ret);
}
My idea is to add new dimension to store string in it without realloc all table of the array and duplicate all old content.
My code isn't working, I get
`"malloc: *** error for object 0x7fff5fbff9e8: pointer being freed was not allocated
set a breakpoint in malloc_error_break to debug"`
I'm just looking to free the second array dimension who store pointer to string.
Any idea ?