1. You should test that file_handle is not NULL after fopen.
2. Your goto is completely pointless. Why not just:
Code:
if (delta_length != 0)
print("%s\n", delta);
...
3. realloc doesn't add memory, it sets the allocation to the given size. You're only ever asking for 1 byte (and since you already have that, realloc is probably doing nothing). So something like:
Code:
delta_length++;
void *newmem = realloc(delta, delta_length + 1);
if (newmem == NULL) {
perror("realloc");
free(delta);
exit(EXIT_FAILURE);
}
delta = newmem;
Note that I used a separate variable to receive realloc's return value just in case it's NULL. That way we still have access to delta's old value so we can free the memory (or whatever).
4. We would never actually realloc a byte at a time like this. It's inefficient and pointless. Normally you would start out with some reasonable size (say 10 bytes) and then double that each realloc (or maybe multiply it by 3/2).
BTW, you should post your code here (in plain text and in code tags).