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:
Richard Frith-MacDonald 2009-03-10 11:30:16 +00:00
parent 61b93f7a45
commit 8afbc2fcb7
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>
* Headers/Additions/GNUstepBase/GSIArray.h:

View file

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

View file

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