When using the runtime's internal autorelease pool implementation, just pop the

top object off when attempting to retain an autoreleased return value,
main
theraven 14 years ago
parent cec2be9431
commit 4f51f9cd05

15
arc.m

@ -303,6 +303,8 @@ id objc_autorelease(id obj)
id objc_autoreleaseReturnValue(id obj)
{
if (!useARCAutoreleasePool)
{
struct arc_tls* tls = getARCThreadData();
if (NULL != tls)
{
@ -310,6 +312,7 @@ id objc_autoreleaseReturnValue(id obj)
tls->returnRetained = obj;
return obj;
}
}
return objc_autorelease(obj);
}
@ -326,7 +329,17 @@ id objc_retainAutoreleasedReturnValue(id obj)
struct arc_tls* tls = getARCThreadData();
if (NULL != tls)
{
if (obj == tls->returnRetained)
// If we're using our own autorelease pool, just pop the object from the top
if (useARCAutoreleasePool)
{
if ((NULL != tls->pool) &&
(*(tls->pool->insert-1) == obj))
{
tls->pool->insert--;
return obj;
}
}
else if (obj == tls->returnRetained)
{
tls->returnRetained = NULL;
return obj;

Loading…
Cancel
Save