include files bug?
Joerg Sonnenberger
joerg at britannica.bec.de
Tue Aug 16 14:29:57 PDT 2005
On Tue, Aug 16, 2005 at 05:45:03PM -0000, Andreas Hauser wrote:
> Maybe if you point me to the discussion in the archives, i can
> read up why this was necessary and what the pros and cons for
> this solution are.
The reason are two things:
(a) exporting the real FILE structure in stdio.h is bad, because
application programmers try to access it directly. That happened in the
past often enough to invent the hack of pointing to a second storage
e.g. for wchar buffer, mutex etc.
(b) It prevents applications from copying FILEs which would result in
segfaults or other corruptions if you try to use them.
I want to be able to change the internals of FILE in libc without
changing the external ABI. The way it is implemented is the safest
version to enforce programs not to mess with FILEs.
I don't think that sizeof(FILE) matters for garbage collectors with
water marks, because e.g. the IO buffers are normally managed by libc,
so they wouldn't be counted. Memory might be allocated internally e.g.
for getc / ungetc too.
Joerg
More information about the Bugs
mailing list