From 09cccdbd3e8615d655c1c771f53cef7dd5f4babe Mon Sep 17 00:00:00 2001 From: rfm Date: Wed, 15 Apr 2009 08:31:14 +0000 Subject: [PATCH] Fix swizzle git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28222 72102866-910b-0410-8b05-ffd578937521 --- Source/NSObject.m | 64 ++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/Source/NSObject.m b/Source/NSObject.m index 916a38444..eb5479b46 100644 --- a/Source/NSObject.m +++ b/Source/NSObject.m @@ -523,37 +523,6 @@ GSIsFinalizable(Class c) return NO; } -void -GSPrivateSwizzle(id o, Class c) -{ - if (o->class_pointer != c) - { -#if GS_WITH_GC - /* We only do allocation counting for objects that can be - * finalised - for other objects we have no way of decrementing - * the count when the object is collected. - */ - if (GSIsFinalizable(o->class_pointer)) - { - /* Already finalizable, so we just need to do any allocation - * accounting. - */ - AREM(o->class_pointer, o); - AADD(c, o); - } - else if (GSIsFinalizable(c)) - { - /* New clas is finalizable, so we must register the instance - * for finalisation and do allocation acounting for it. - */ - AADD(c, o); - GC_REGISTER_FINALIZER (o, GSFinalize, NULL, NULL, NULL); - } -#endif /* GS_WITH_GC */ - o->class_pointer = c; - } -} - inline NSObject * NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone) { @@ -666,6 +635,39 @@ NSDeallocateObject(NSObject *anObject) #endif /* GS_WITH_GC */ + +void +GSPrivateSwizzle(id o, Class c) +{ + if (o->class_pointer != c) + { +#if GS_WITH_GC + /* We only do allocation counting for objects that can be + * finalised - for other objects we have no way of decrementing + * the count when the object is collected. + */ + if (GSIsFinalizable(o->class_pointer)) + { + /* Already finalizable, so we just need to do any allocation + * accounting. + */ + AREM(o->class_pointer, o); + AADD(c, o); + } + else if (GSIsFinalizable(c)) + { + /* New clas is finalizable, so we must register the instance + * for finalisation and do allocation acounting for it. + */ + AADD(c, o); + GC_REGISTER_FINALIZER (o, GSFinalize, NULL, NULL, NULL); + } +#endif /* GS_WITH_GC */ + o->class_pointer = c; + } +} + + BOOL NSShouldRetainWithZone (NSObject *anObject, NSZone *requestedZone) {