> If `bp2' doesn't point to a pointer returned by realloc, malloc or
> calloc, realloc() will produce undefined results (unless `bp2's value
> is NULL)
> But I *see* what you are trying to do, here's the actual logic:
> size_t n = 0;
> back:
> if(fread(&bp2[n], sizeof bp2[0], 1, fp) != 1) { /* handle error or EOF
> */ }
> n++;
> bp2 = realloc(bp2, n+1 * sizeof bp2[0]);
> if(bp2 == NULL) { /* ... */ }
> goto back;
thanks, this helped a lot. i just didn't know i can use bp2 just as
normal array.


|