mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
removal of garbage collection
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@39608 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
030f54a9cf
commit
d40d219015
72 changed files with 122 additions and 1787 deletions
|
@ -42,9 +42,6 @@
|
|||
static SEL eqSel;
|
||||
static SEL oaiSel;
|
||||
|
||||
#if GS_WITH_GC
|
||||
static Class GSArrayClass;
|
||||
#else
|
||||
static Class GSInlineArrayClass;
|
||||
/* This class stores objects inline in data beyond the end of the instance.
|
||||
* However, when GC is enabled the object data is typed, and all data after
|
||||
|
@ -56,7 +53,6 @@ static Class GSInlineArrayClass;
|
|||
{
|
||||
}
|
||||
@end
|
||||
#endif
|
||||
|
||||
@class GSArray;
|
||||
|
||||
|
@ -105,11 +101,7 @@ static Class GSInlineArrayClass;
|
|||
[self setVersion: 1];
|
||||
eqSel = @selector(isEqual:);
|
||||
oaiSel = @selector(objectAtIndex:);
|
||||
#if GS_WITH_GC
|
||||
GSArrayClass = [GSArray class];
|
||||
#else
|
||||
GSInlineArrayClass = [GSInlineArray class];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,14 +121,12 @@ static Class GSInlineArrayClass;
|
|||
{
|
||||
if (_contents_array)
|
||||
{
|
||||
#if !GS_WITH_GC
|
||||
NSUInteger i;
|
||||
|
||||
for (i = 0; i < _count; i++)
|
||||
{
|
||||
[_contents_array[i] release];
|
||||
}
|
||||
#endif
|
||||
NSZoneFree([self zone], _contents_array);
|
||||
_contents_array = 0;
|
||||
}
|
||||
|
@ -155,12 +145,7 @@ static Class GSInlineArrayClass;
|
|||
{
|
||||
NSUInteger i;
|
||||
|
||||
#if GS_WITH_GC
|
||||
_contents_array = NSAllocateCollectable(sizeof(id)*count,
|
||||
NSScannedOption);
|
||||
#else
|
||||
_contents_array = NSZoneMalloc([self zone], sizeof(id)*count);
|
||||
#endif
|
||||
if (_contents_array == 0)
|
||||
{
|
||||
DESTROY(self);
|
||||
|
@ -217,12 +202,7 @@ static Class GSInlineArrayClass;
|
|||
at: &_count];
|
||||
if (_count > 0)
|
||||
{
|
||||
#if GS_WITH_GC
|
||||
_contents_array = NSAllocateCollectable(sizeof(id) * _count,
|
||||
NSScannedOption);
|
||||
#else
|
||||
_contents_array = NSZoneCalloc([self zone], _count, sizeof(id));
|
||||
#endif
|
||||
if (_contents_array == 0)
|
||||
{
|
||||
[NSException raise: NSMallocException
|
||||
|
@ -395,7 +375,6 @@ static Class GSInlineArrayClass;
|
|||
|
||||
@end
|
||||
|
||||
#if !GS_WITH_GC
|
||||
@implementation GSInlineArray
|
||||
- (void) dealloc
|
||||
{
|
||||
|
@ -439,7 +418,6 @@ static Class GSInlineArrayClass;
|
|||
return self;
|
||||
}
|
||||
@end
|
||||
#endif
|
||||
|
||||
@implementation GSMutableArray
|
||||
|
||||
|
@ -487,11 +465,7 @@ static Class GSInlineArrayClass;
|
|||
{
|
||||
NSArray *copy;
|
||||
|
||||
#if GS_WITH_GC
|
||||
copy = (id)NSAllocateObject(GSArrayClass, 0, zone);
|
||||
#else
|
||||
copy = (id)NSAllocateObject(GSInlineArrayClass, sizeof(id)*_count, zone);
|
||||
#endif
|
||||
return [copy initWithObjects: _contents_array count: _count];
|
||||
}
|
||||
|
||||
|
@ -528,11 +502,7 @@ static Class GSInlineArrayClass;
|
|||
{
|
||||
cap = 1;
|
||||
}
|
||||
#if GS_WITH_GC
|
||||
_contents_array = NSAllocateCollectable(sizeof(id)*cap, NSScannedOption);
|
||||
#else
|
||||
_contents_array = NSZoneMalloc([self zone], sizeof(id)*cap);
|
||||
#endif
|
||||
_capacity = cap;
|
||||
_grow_factor = cap > 1 ? cap/2 : 1;
|
||||
return self;
|
||||
|
@ -655,16 +625,13 @@ static Class GSInlineArrayClass;
|
|||
|
||||
if ((pos = _count) > 0)
|
||||
{
|
||||
#if GS_WITH_GC == 0
|
||||
IMP rel = 0;
|
||||
Class last = Nil;
|
||||
#endif
|
||||
|
||||
_version++;
|
||||
_count = 0;
|
||||
while (pos-- > 0)
|
||||
{
|
||||
#if GS_WITH_GC == 0
|
||||
id o = _contents_array[pos];
|
||||
Class c = object_getClass(o);
|
||||
|
||||
|
@ -674,7 +641,6 @@ static Class GSInlineArrayClass;
|
|||
rel = [o methodForSelector: @selector(release)];
|
||||
}
|
||||
(*rel)(o, @selector(release));
|
||||
#endif
|
||||
_contents_array[pos] = nil;
|
||||
}
|
||||
_version++;
|
||||
|
@ -709,9 +675,7 @@ static Class GSInlineArrayClass;
|
|||
if (index > 0)
|
||||
{
|
||||
BOOL (*imp)(id,SEL,id);
|
||||
#if GS_WITH_GC == 0
|
||||
BOOL retained = NO;
|
||||
#endif
|
||||
|
||||
imp = (BOOL (*)(id,SEL,id))[anObject methodForSelector: eqSel];
|
||||
while (index-- > 0)
|
||||
|
@ -719,15 +683,13 @@ static Class GSInlineArrayClass;
|
|||
if ((*imp)(anObject, eqSel, _contents_array[index]) == YES)
|
||||
{
|
||||
NSUInteger pos = index;
|
||||
#if GS_WITH_GC == 0
|
||||
id obj = _contents_array[index];
|
||||
id obj = _contents_array[index];
|
||||
|
||||
if (retained == NO)
|
||||
{
|
||||
RETAIN(anObject);
|
||||
retained = YES;
|
||||
}
|
||||
#endif
|
||||
|
||||
while (++pos < _count)
|
||||
{
|
||||
|
@ -738,12 +700,10 @@ static Class GSInlineArrayClass;
|
|||
RELEASE(obj);
|
||||
}
|
||||
}
|
||||
#if GS_WITH_GC == 0
|
||||
if (retained == YES)
|
||||
{
|
||||
RELEASE(anObject);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
_version++;
|
||||
}
|
||||
|
@ -784,9 +744,7 @@ static Class GSInlineArrayClass;
|
|||
{
|
||||
if (_contents_array[index] == anObject)
|
||||
{
|
||||
#if GS_WITH_GC == 0
|
||||
id obj = _contents_array[index];
|
||||
#endif
|
||||
NSUInteger pos = index;
|
||||
|
||||
while (++pos < _count)
|
||||
|
@ -810,15 +768,12 @@ static Class GSInlineArrayClass;
|
|||
NSUInteger index;
|
||||
NSUInteger tail;
|
||||
NSUInteger end;
|
||||
#if GS_WITH_GC == 0
|
||||
IMP rel = 0;
|
||||
Class last = Nil;
|
||||
#endif
|
||||
|
||||
_version++;
|
||||
index = aRange.location;
|
||||
|
||||
#if GS_WITH_GC == 0
|
||||
/* Release all the objects we are removing.
|
||||
*/
|
||||
end = NSMaxRange(aRange);
|
||||
|
@ -835,7 +790,7 @@ static Class GSInlineArrayClass;
|
|||
(*rel)(o, @selector(release));
|
||||
_contents_array[end] = nil;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Move any trailing objects to fill the hole we made.
|
||||
*/
|
||||
end = NSMaxRange(aRange);
|
||||
|
@ -1172,11 +1127,7 @@ static Class GSInlineArrayClass;
|
|||
|
||||
+ (void) initialize
|
||||
{
|
||||
#if GS_WITH_GC
|
||||
GSArrayClass = [GSArray class];
|
||||
#else
|
||||
GSInlineArrayClass = [GSInlineArray class];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (id) autorelease
|
||||
|
@ -1219,14 +1170,7 @@ static Class GSInlineArrayClass;
|
|||
}
|
||||
else
|
||||
{
|
||||
unsigned c;
|
||||
#if GS_WITH_GC
|
||||
GSArray *a;
|
||||
|
||||
[aCoder decodeValueOfObjCType: @encode(unsigned) at: &c];
|
||||
a = (id)NSAllocateObject(GSArrayClass, 0, [self zone]);
|
||||
a->_contents_array = NSAllocateCollectable(sizeof(id)*c, NSScannedOption);
|
||||
#else
|
||||
unsigned c;
|
||||
GSInlineArray *a;
|
||||
|
||||
[aCoder decodeValueOfObjCType: @encode(unsigned) at: &c];
|
||||
|
@ -1234,7 +1178,6 @@ static Class GSInlineArrayClass;
|
|||
sizeof(id)*c, [self zone]);
|
||||
a->_contents_array
|
||||
= (id*)(((void*)a) + class_getInstanceSize([a class]));
|
||||
#endif
|
||||
if (c > 0)
|
||||
{
|
||||
[aCoder decodeArrayOfObjCType: @encode(id)
|
||||
|
@ -1248,12 +1191,8 @@ static Class GSInlineArrayClass;
|
|||
|
||||
- (id) initWithObjects: (const id[])objects count: (NSUInteger)count
|
||||
{
|
||||
#if GS_WITH_GC
|
||||
self = (id)NSAllocateObject(GSArrayClass, 0, [self zone]);
|
||||
#else
|
||||
self = (id)NSAllocateObject(GSInlineArrayClass, sizeof(id)*count,
|
||||
[self zone]);
|
||||
#endif
|
||||
return [self initWithObjects: objects count: count];
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue