mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-29 16:01:38 +00:00
Tidyups for garbage collection
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@4952 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
775722b78e
commit
cc7cb05157
6 changed files with 57 additions and 58 deletions
|
@ -281,42 +281,37 @@ static void
|
|||
GSFinalize(void* object, void* data)
|
||||
{
|
||||
[(id)object gcFinalize];
|
||||
|
||||
/* Set the class of anObject to FREED_OBJECT. The further messages to this
|
||||
object will cause an error to occur. */
|
||||
((id)object)->class_pointer = __freedObjectClass;
|
||||
|
||||
#ifndef NDEBUG
|
||||
GSDebugAllocationRemove(((id)object)->class_pointer);
|
||||
#endif
|
||||
((id)object)->class_pointer = (void*) 0xdeadface;
|
||||
((id)object)->class_pointer = (void*)0xdeadface;
|
||||
}
|
||||
|
||||
inline NSObject *
|
||||
NSAllocateObject (Class aClass, unsigned extraBytes, NSZone *zone)
|
||||
NSAllocateObject(Class aClass, unsigned extraBytes, NSZone *zone)
|
||||
{
|
||||
id new = nil;
|
||||
int size = aClass->instance_size + extraBytes;
|
||||
if (CLS_ISCLASS (aClass))
|
||||
new = NSZoneMalloc (zone, size);
|
||||
id new = nil;
|
||||
int size = aClass->instance_size + extraBytes;
|
||||
|
||||
if (CLS_ISCLASS(aClass))
|
||||
new = NSZoneMalloc(zone, size);
|
||||
if (new != nil)
|
||||
{
|
||||
memset (new, 0, size);
|
||||
memset(new, 0, size);
|
||||
new->class_pointer = aClass;
|
||||
}
|
||||
if ([new respondsToSelector: @selector(gcFinalize)])
|
||||
{
|
||||
if (__objc_responds_to(new, @selector(gcFinalize)))
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
GSDebugAllocationAdd(aClass);
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
GSDebugAllocationAdd(aClass);
|
||||
#endif
|
||||
GC_REGISTER_FINALIZER (new, GSFinalize, NULL, NULL, NULL);
|
||||
GC_REGISTER_FINALIZER (new, GSFinalize, NULL, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
|
|
|
@ -1759,11 +1759,9 @@ NSZoneStats (NSZone *zone)
|
|||
#else
|
||||
|
||||
/*
|
||||
* Dummy zone used with garbage collection.
|
||||
* In some places we make a distinction between the nul zone and the dummy
|
||||
* zone - items pointed to by memory in the nul zone can be deallocated by
|
||||
* the gc mechanism, while those pointed to from memory in the dummy zone
|
||||
* can't.
|
||||
* Dummy zones used with garbage collection.
|
||||
* The 'atomic' zone is for memory that will be assumed not to contain
|
||||
* pointers for garbage collection purposes.
|
||||
*/
|
||||
static NSZone default_zone =
|
||||
{
|
||||
|
@ -1771,5 +1769,11 @@ static NSZone default_zone =
|
|||
};
|
||||
NSZone* __nszone_private_hidden_default_zone = &default_zone;
|
||||
|
||||
static NSZone atomic_zone =
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, @"default", 0
|
||||
};
|
||||
NSZone* __nszone_private_hidden_atomic_zone = &atomic_zone;
|
||||
|
||||
#endif /* GS_WITH_GC */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue