Question on stdio standard behaviour (Bugreport libc/755)

Wolfram Gloger wmglo@dent.med.uni-muenchen.de
Tue Aug 25 01:37:00 GMT 1998


> we've received the appended bugreport.  The essence is that "perl
> expects that fclose followed by fopen will return the same pointer".
> This works on most platforms but not with libc5 and glibc2.

Considering that FILE structures are allocated with malloc(), this is
a completely bogus assumption, IMHO.  It boils down to the assumption
that ptr=malloc(size); ... ; free(ptr); ptr2=malloc(size); will always
yield ptr2==ptr.  Only very simple mallocs do guarantee this, and it
will likely break down for multiple threads in any case.

It may be possible to fulfill the assumption if the FILE structures
for stdin/stdout/stderr are allocated statically, but I don't think it
is worth it....

Regards,
Wolfram.



More information about the Libc-hacker mailing list