From 6f4f708a6fce31cd37745664d89d80d6f8663d1b Mon Sep 17 00:00:00 2001 From: Richard Frith-MacDonald Date: Fri, 11 Feb 2011 16:04:05 +0000 Subject: [PATCH] Reduce internal class interdependency for improved maintainability. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32083 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 2 ++ Source/NSAutoreleasePool.m | 30 +++++++++++++++++------------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index d981a92fc..a32f9d828 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ * Source/NSKeyValueObserving.m: Recommit Reviewed and tested. + * Source/NAutoreleasePool.m: Make +initialize do nothing so that it + won't interfere with anythign else when called by [NSObject+initialize] 2011-02-11 Richard Frith-Macdonald diff --git a/Source/NSAutoreleasePool.m b/Source/NSAutoreleasePool.m index e2b076199..a4eb1b41f 100644 --- a/Source/NSAutoreleasePool.m +++ b/Source/NSAutoreleasePool.m @@ -111,22 +111,15 @@ pop_pool_from_cache (struct autorelease_thread_vars *tv) return tv->pool_cache[--(tv->pool_cache_count)]; } -static SEL releaseSel = 0; - @implementation NSAutoreleasePool -static IMP allocImp; -static IMP initImp; - + (void) initialize { - if (self == [NSAutoreleasePool class]) - { - releaseSel = @selector(release); - allocImp = [self methodForSelector: @selector(allocWithZone:)]; - initImp = [self instanceMethodForSelector: @selector(init)]; - } + /* Do nothing here which might interact with ther classes since this + * is called by [NSObject+initialize] ! + */ + return; } + (id) allocWithZone: (NSZone*)zone @@ -140,7 +133,18 @@ static IMP initImp; + (id) new { - id arp = (*allocImp)(self, @selector(allocWithZone:), NSDefaultMallocZone()); + static IMP allocImp = 0; + static IMP initImp = 0; + id arp; + + if (0 == allocImp) + { + allocImp + = [NSAutoreleasePool methodForSelector: @selector(allocWithZone:)]; + initImp + = [NSAutoreleasePool instanceMethodForSelector: @selector(init)]; + } + arp = (*allocImp)(self, @selector(allocWithZone:), NSDefaultMallocZone()); return (*initImp)(arp, @selector(init)); } @@ -438,7 +442,7 @@ static IMP initImp; imps[hash] = get_imp(c, @selector(release)); classes[hash] = c; } - (imps[hash])(anObject, releaseSel); + (imps[hash])(anObject, @selector(release)); } _released_count -= released->count; released->count = 0;