Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!ucsd!mvb.saic.com!unogate!unocal!genisco!arcturus!felix!ka@felix.UUCP From: ka@felix.UUCP (Kenneth Almquist) Newsgroups: comp.unix.internals Subject: Re: Shared Lib Question (ISC) Message-ID: <162950@felix.UUCP> Date: 18 May 91 01:33:46 GMT References: <276@rwing.UUCP> <162@titccy.cc.titech.ac.jp> <19252@rpp386.cactus.org> <19255@rpp386.cactus.org> Sender: daemon@felix.UUCP Organization: FileNet Corp., Costa Mesa, CA Lines: 21 jfh@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