Shared Lib Question (ISC)
Kenneth Almquist
ka at felix.UUCP
Sat May 18 11:33:46 AEST 1991
jfh at rpp386.cactus.org (John F Haugh II) writes:
>>>Were the code in the C library pure, shared libraries would
>>>be extremely simple to implement.
and later challenges:
> Name a single library function which cannot be implemented well
> without global variables. Justify your answer.
How about:
1) getpwent and relatives -- needs global variables to hold the current
state and the returned passwd structure. (Placing these in a structure
which is passed to getpwent would complicate the calling program,
especially if the passwd file is examined in several places.)
2) malloc/realloc/free -- requires a global data structure to keep track
of which areas of memory are free.
3) stdio/exit -- needs a global variable so that exit can locate and close
all open files.
Kenneth Almquist
More information about the Comp.unix.internals
mailing list