More GC updates

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@4958 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 1999-09-29 14:13:52 +00:00
parent 18f87db0c7
commit 78e6f68250
5 changed files with 125 additions and 2 deletions

View file

@ -1758,6 +1758,8 @@ NSZoneStats (NSZone *zone)
#else
#include <gc.h>
/*
* Dummy zones used with garbage collection.
* The 'atomic' zone is for memory that will be assumed not to contain
@ -1775,5 +1777,89 @@ static NSZone atomic_zone =
};
NSZone* __nszone_private_hidden_atomic_zone = &atomic_zone;
NSZone* NSCreateZone (size_t start, size_t gran, BOOL canFree)
{ return __nszone_private_hidden_default_zone; }
NSZone* NSDefaultMallocZone (void)
{ return __nszone_private_hidden_default_zone; }
NSZone* GSAtomicMallocZone (void)
{ return __nszone_private_hidden_atomic_zone; }
NSZone* NSZoneFromPointer (void *ptr)
{ return __nszone_private_hidden_default_zone; }
void* NSZoneMalloc (NSZone *zone, size_t size)
{
void *ptr;
if (zone == GSAtomicMallocZone())
ptr = (void*)GC_MALLOC_ATOMIC(size);
else
ptr = (void*)GC_MALLOC(size);
if (ptr == 0)
ptr = GSOutOfMemory(size, YES);
return ptr;
}
void* NSZoneCalloc (NSZone *zone, size_t elems, size_t bytes)
{
size_t size = elems * bytes;
void *ptr;
if (zone == __nszone_private_hidden_atomic_zone)
ptr = (void*)GC_MALLOC_ATOMIC(size);
else
ptr = (void*)GC_MALLOC(size);
if (ptr == 0)
ptr = GSOutOfMemory(size, NO);
memset(ptr, '\0', size);
return ptr;
}
void* NSZoneRealloc (NSZone *zone, void *ptr, size_t size)
{
ptr = GC_REALLOC(ptr, size);
if (ptr == 0)
GSOutOfMemory(size, NO);
return ptr;
}
void NSRecycleZone (NSZone *zone)
{
}
void NSZoneFree (NSZone *zone, void *ptr)
{
GC_FREE(ptr);
}
void NSSetZoneName (NSZone *zone, NSString *name)
{
}
NSString* NSZoneName (NSZone *zone)
{
return nil;
}
void* NSZoneMallocAtomic (NSZone *zone, size_t size)
{
return NSZoneMalloc(GSAtomicMallocZone(), size);
}
BOOL NSZoneCheck (NSZone *zone)
{
return YES;
}
struct NSZoneStats NSZoneStats (NSZone *zone)
{
struct NSZoneStats stats = { 0 };
return stats;
}
#endif /* GS_WITH_GC */