diff --git a/arc.m b/arc.m index 1a4f7773..687651b1 100644 --- a/arc.m +++ b/arc.m @@ -45,7 +45,7 @@ static inline DWORD arc_tls_key_create(void WINAPI(*cleanupFunction)(void*)) extern void _NSConcreteMallocBlock; extern void _NSConcreteStackBlock; -extern void _NSConcreteGlobalBlock; +extern struct objc_class _NSConcreteGlobalBlock; @interface NSAutoreleasePool + (Class)class; @@ -190,6 +190,12 @@ static inline id retain(id obj) { if (isSmallObject(obj)) { return obj; } Class cls = obj->isa; + + if ((Class)&_NSConcreteGlobalBlock == cls->isa) + { + cls = cls->isa; + } + if ((Class)&_NSConcreteMallocBlock == cls || (Class)&_NSConcreteStackBlock == cls) { @@ -214,13 +220,14 @@ static inline void release(id obj) { if (isSmallObject(obj)) { return; } Class cls = obj->isa; + if (cls == &_NSConcreteMallocBlock) { _Block_release(obj); return; } if ((cls == &_NSConcreteStackBlock) || - (cls == &_NSConcreteGlobalBlock)) + (cls->isa == &_NSConcreteGlobalBlock)) { return; } diff --git a/class.h b/class.h index 8da94eb2..e41afac4 100644 --- a/class.h +++ b/class.h @@ -300,6 +300,10 @@ static inline Class classForObject(id obj) return SmallObjectClasses[(addr & OBJC_SMALL_OBJECT_MASK)]; } } + extern struct objc_class _NSConcreteGlobalBlock; + if (obj->isa->isa == (Class)&_NSConcreteGlobalBlock) { + return (Class)&_NSConcreteGlobalBlock; + } return obj->isa; }