There's a destructor function associated with the thread-specific
memory that is responsible for cleaning up when the thread exits.
See the pthread_exit(3) man page. Each of the Libinfo routines
attaches an appropriate destructor function, so the memory is not
supposed to leak when the thread exits. If you are seeing a memory
leak after a thread exits, let me know and I'll dig into it.
--
Marc Majka
On 3 Aug, 2005, at 15:13, Martin Bestmann wrote:
Does this also mean when the thread terminates that the memory gets
recycled.
I could verify that the memory in the same thread gets recycled if
I call getpwuid but I still have the memory allocated after my
thread terminates.
On 03.08.2005, at 23:40, Marc Majka wrote:
The Mac OS X implementations of a number of routines found in
libSystem, including getpwnam and getpwuid, have been modified to
be thread-safe. Rather than returning a pointer to a static data
structure, these routines allocate a structure for the returned
value that is stored in thread-specific memory. The memory is
recycled (by each thread) every time you make a call to one of
these routines. That allows you to use these APIs safely in multi-
threaded applications.
The specific routines in the Libinfo project (see Libinfo/
lookup.subproj/lu_*.c) that maintain thread-specific memory for
results are:
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-dev/email@hidden