I have this function:
static void unfoldLines(char **pbuff, char **lines, int foldCount) {
int i, j;
for(i = 1; i <= foldCount; i++) {
removeEOL(lines[i]);
for(j = 0; j < strlen(lines[i]); j++) {
while(isspace(lines[i][j])) {
lines[i]++;
}
}
}
lines[1] = realloc(lines[1], sizeof(char) * (strlen(lines[1]) +
strlen(lines[2]) + 1));
exit(0);
}
lines and it's pointers has been malloced in a previous function. When I try to realloc lines[1], I get this error:
malloc: *** error for object 0x7fcec0404fe1: pointer being realloc'd was not allocated
I know it has been malloced, so why can't it be realloced in this function?