GC bugfixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28062 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2009-03-10 11:30:16 +00:00
parent a9c800575e
commit 8bbcafb4c1
3 changed files with 33 additions and 8 deletions

View file

@ -1,3 +1,11 @@
2009-03-10 Richard Frith-Macdonald <rfm@gnu.org>
* Headers/Additions/GNUstepBase/GSIArray.h:
* Source/NSNotificationCenter.m:
* Source/NSRunLoop.m:
* Source/NSZone.m:
Various small GC bugfixes to get more of testsuite passing.
2009-03-09 Richard Frith-Macdonald <rfm@gnu.org> 2009-03-09 Richard Frith-Macdonald <rfm@gnu.org>
* Headers/Additions/GNUstepBase/GSIArray.h: * Headers/Additions/GNUstepBase/GSIArray.h:

View file

@ -447,7 +447,12 @@ GSIArrayRemoveItemAtIndex(GSIArray array, unsigned index)
while (++index < array->count) while (++index < array->count)
array->ptr[index-1] = array->ptr[index]; array->ptr[index-1] = array->ptr[index];
array->count--; array->count--;
#if !defined(GS_NO_RELEASE)
#if GS_WITH_GC
array->ptr[array->count] = (GSIArrayItem)(NSUInteger)0;
#endif
GSI_ARRAY_RELEASE(array, tmp); GSI_ARRAY_RELEASE(array, tmp);
#endif
} }
static INLINE void static INLINE void
@ -456,8 +461,13 @@ GSIArrayRemoveLastItem(GSIArray array)
#ifdef GSI_ARRAY_CHECKS #ifdef GSI_ARRAY_CHECKS
NSCAssert(array->count, NSInvalidArgumentException); NSCAssert(array->count, NSInvalidArgumentException);
#endif #endif
GSI_ARRAY_RELEASE(array, array->ptr[array->count-1]);
array->count--; array->count--;
#if !defined(GS_NO_RELEASE)
GSI_ARRAY_RELEASE(array, array->ptr[array->count]);
#if GS_WITH_GC
array->ptr[array->count] = (GSIArrayItem)(NSUInteger)0;
#endif
#endif
} }
static INLINE void static INLINE void
@ -471,6 +481,9 @@ GSIArrayRemoveItemAtIndexNoRelease(GSIArray array, unsigned index)
while (++index < array->count) while (++index < array->count)
array->ptr[index-1] = array->ptr[index]; array->ptr[index-1] = array->ptr[index];
array->count--; array->count--;
#if GS_WITH_GC && !defined(GS_NO_RELEASE)
array->ptr[array->count] = (GSIArrayItem)(NSUInteger)0;
#endif
} }
static INLINE void static INLINE void
@ -542,6 +555,9 @@ GSIArrayRemoveItemsFromIndex(GSIArray array, unsigned index)
while (array->count-- > index) while (array->count-- > index)
{ {
GSI_ARRAY_RELEASE(array, array->ptr[array->count]); GSI_ARRAY_RELEASE(array, array->ptr[array->count]);
#if GS_WITH_GC
array->ptr[array->count] = (GSIArrayItem)(NSUInteger)0;
#endif
} }
#endif #endif
array->count = index; array->count = index;
@ -555,6 +571,9 @@ GSIArrayRemoveAllItems(GSIArray array)
while (array->count--) while (array->count--)
{ {
GSI_ARRAY_RELEASE(array, array->ptr[array->count]); GSI_ARRAY_RELEASE(array, array->ptr[array->count]);
#if GS_WITH_GC
array->ptr[array->count] = (GSIArrayItem)(NSUInteger)0;
#endif
} }
#endif #endif
array->count = 0; array->count = 0;

View file

@ -746,26 +746,23 @@ static inline BOOL timerInvalidated(NSTimer *t)
NSObjectMapValueCallBacks, 0); NSObjectMapValueCallBacks, 0);
_timedPerformers = [[NSMutableArray alloc] initWithCapacity: 8]; _timedPerformers = [[NSMutableArray alloc] initWithCapacity: 8];
#ifdef HAVE_POLL_F #ifdef HAVE_POLL_F
#if GS_WITH_GC
_extra = NSAllocateCollectable(sizeof(pollextra), NSScannedOption);
#else
_extra = NSZoneMalloc(NSDefaultMallocZone(), sizeof(pollextra)); _extra = NSZoneMalloc(NSDefaultMallocZone(), sizeof(pollextra));
memset(_extra, '\0', sizeof(pollextra)); memset(_extra, '\0', sizeof(pollextra));
#endif
#endif #endif
} }
return self; return self;
} }
- (void) dealloc - (void) dealloc
{
[self finalize];
[super dealloc];
}
- (void) finalize
{ {
#ifdef HAVE_POLL_F #ifdef HAVE_POLL_F
if (_extra != 0) if (_extra != 0)
{ {
pollextra *e = (pollextra*)_extra; pollextra *e = (pollextra*)_extra;
if (e->index != 0) if (e->index != 0)
NSZoneFree(NSDefaultMallocZone(), e->index); NSZoneFree(NSDefaultMallocZone(), e->index);
NSZoneFree(NSDefaultMallocZone(), e); NSZoneFree(NSDefaultMallocZone(), e);
@ -777,6 +774,7 @@ static inline BOOL timerInvalidated(NSTimer *t)
NSFreeMapTable(_contextMap); NSFreeMapTable(_contextMap);
} }
RELEASE(_timedPerformers); RELEASE(_timedPerformers);
[super dealloc];
} }
/** /**