Date: Fri, 12 Sep 1997 18:40:53 -0500 From: Carl Fongheiser <cmf@netins.net> To: Terry Lambert <tlambert@primenet.com> Cc: freebsd-hackers@freebsd.org Subject: Re: Memory leak in getservbyXXX? Message-ID: <v03102800b03f82900eec@[44.50.32.7]>
next in thread | raw e-mail | index | archive | help
>To the user: you should note that the threaded libc differs from the >standard libc in that, instead of returning pointers to function >modified static data areas, most functions which formerly did just >that now return allocated buffers which contain the results, and it >is now the user's responsibility to free these buffers. > >The use of static data buffers in libc is a long-standing abomination, >blessed by ANSI and codified in stone by POSIX. Assume any man page >which states a pointer to a static data area is returned is actually >allocating a data area and expecting the caller to free it, whenever >you are using a thread-safe library. It may be an abomination, but it's also a fact of life. The pthread interface *does* provide a way to cope -- check out pthread_key_create(), pthread_setspecific() and pthread_getspecific(). You even get to specify a destructor routine, so you can automagically clean up your allocated buffers inside the library! Carl Fongheiser cmf@netins.net
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?v03102800b03f82900eec>