yes thanks Salem, I have a fully working function.
I dont think that i can always terminate the string with a null within the loop because getc stops when it reaches the EOF, the loop is broken before I can insert a NULL so I have to do it outside... right?
Safe realloc is a thin wrapper :
Code:
void *safe_realloc (void *old, size_t bytes)
{
void *new;
assert (bytes > 0);
if ((new = realloc (old, bytes)) == NULL)
{
fprintf (stderr, "Fatal memory allocation failure, aborting\n");
exit (EXIT_FAILURE);
}
return new;
}
to deal have realloc behave more safely.
I thought i needed to cast a void pointer to the type on return... right/wrong?