Make sure that autoreleased returned objects are destroyed when the autorelease

pool is destroyed.  They were previously being destroyed on thread termination,
this ensures that their lifespan is predictable.
This commit is contained in:
theraven 2011-07-04 12:22:23 +00:00
parent 7155f174b7
commit 9d6154041c

7
arc.m
View File

@ -91,6 +91,13 @@ void objc_autoreleasePoolPop(void *pool)
// TODO: Keep a small pool of autorelease pools per thread and allocate
// from there.
DeleteAutoreleasePool(pool, SELECTOR(release));
#ifndef NO_PTHREADS
// Ensure that autoreleased return values are destroyed at the correct
// moment.
id tmp = pthread_getspecific(ReturnRetained);
objc_release(tmp);
pthread_setspecific(ReturnRetained, NULL);
#endif
}
id objc_autorelease(id obj)