Since this only returns NULL, why do you have it return anything?
Code:
void * findEnds ( char * input ) {
int len, x, y, z, n;
char * endString = calloc(sizeof(char), 1024);
char * filename = calloc(sizeof(char), 1024);
char * smallString = calloc(sizeof(char), 9);
len = strlen(input);
for (x = len; x > 0; x--) {
printf ("\%c|%c/%c-%c", 8, 8, 8, 8);
if (input[x] == 49) {
z = x + 1;
endString = substr(input, 0, z);
y = strlen(endString);
sprintf(filename, "len/%d.txt", y);
printChars(endString, filename);
}
}
/* realloc(endString, 0); */
realloc(filename, 0);
realloc(smallString, 0);
return NULL;
}
Just make it a void function? Additionally, why is "smallString" in this function? It is never used. Also, you don't need 1KB for your file name, since it will only ever be 19 characters in length maximum, including the null. In this case, there is really no need to calloc string space. Simply use a 19 character buffer.
char filename[19];
sprintf( filename, "len/%d.txt", y );
Still unsure why you cannot realloc the one, but I just thought I'd run those suggestions by you. If you can't free that, definately you're going to eat up memory every time you call this function.
Quzah.