On Thu, 9 Mar 2000, Per Mildner wrote:

> The fix is not that xrealloc is called. The fix is that the else-part 
> is *not* called. The fact that xrealloc is called instead is just 
> harmless.

Okay, sorry for my misunderstanding.

> The original code stripped of ifdefs looks like:
> 
>    while ((n = read (file, result + count, file_size)) > 0)
>      count += n;
>    if (0 < count && count < file_size)
>      result = xrealloc (result, count + 2);
>    else if (n == -1)
>     <<ERROR>>
> 
> The problem with this is that if count is equal to file_size then the 
> <<ERROR>> code is used.

This is only true if n is -1, which usually is a sign of some error 
during reading.  Is that what happens with the Cygwin version?

> it would be possible to special case this to avoid the call to 
> xrealloc but that is only worth it if xrealloc is doing something 
> stupid when it is asked to realloc something to a size it already has.

I'm not sure we should rely on behavior of realloc.

Reply via email to