mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
More moves towards OSX 10.5 GC compatibility.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28054 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
3a0afe2e58
commit
5cab993ed1
25 changed files with 553 additions and 282 deletions
31
ChangeLog
31
ChangeLog
|
@ -1,3 +1,34 @@
|
|||
2009-03-09 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Headers/Additions/GNUstepBase/GSIArray.h:
|
||||
* Headers/Additions/GNUstepBase/GSIMap.h:
|
||||
* Headers/Foundation/NSZone.h:
|
||||
* Source/Additions/GSInsensitiveDictionary.m:
|
||||
* Source/Additions/Unicode.m:
|
||||
* Source/GSAttributedString.m:
|
||||
* Source/GSCountedSet.m:
|
||||
* Source/GSDictionary.m:
|
||||
* Source/GSPrivate.h:
|
||||
* Source/GSSet.m:
|
||||
* Source/NSArchiver.m:
|
||||
* Source/NSConnection.m:
|
||||
* Source/NSHashTable.m:
|
||||
* Source/NSKeyedArchiver.m:
|
||||
* Source/NSKeyedUnarchiver.m:
|
||||
* Source/NSMapTable.m:
|
||||
* Source/NSNotificationCenter.m:
|
||||
* Source/NSPortCoder.m:
|
||||
* Source/NSRunLoop.m:
|
||||
* Source/NSSerializer.m:
|
||||
* Source/NSURL.m:
|
||||
* Source/NSZone.m:
|
||||
* Source/unix/GSRunLoopCtxt.m:
|
||||
* Source/win32/GSRunLoopCtxt.m:
|
||||
More moves towards OSX 10.5 GC compatibility.
|
||||
With GC add some use of typed memory and remove the old
|
||||
GNUstep specific GSAtomicMallocZone() from public API.
|
||||
Still needs new NSHashTable and NSMaptable implementations.
|
||||
|
||||
2009-03-08 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/GSSocketStream.m:
|
||||
|
|
|
@ -145,9 +145,6 @@ extern "C" {
|
|||
|
||||
#endif /* #ifndef GSIArrayItem */
|
||||
|
||||
static BOOL _GSIArraySetup = NO;
|
||||
static NSGarbageCollector *_GSIArrayCollector = nil;
|
||||
|
||||
struct _GSIArray {
|
||||
GSIArrayItem *ptr;
|
||||
unsigned count;
|
||||
|
@ -193,29 +190,23 @@ GSIArrayGrow(GSIArray array)
|
|||
}
|
||||
next = array->cap + array->old;
|
||||
size = next*sizeof(GSIArrayItem);
|
||||
if (_GSIArrayCollector == nil)
|
||||
{
|
||||
tmp = NSZoneMalloc(array->zone, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp = NSAllocateCollectable(size, array->zone ? NSScannedOption : 0);
|
||||
}
|
||||
#if GS_WITH_GC
|
||||
tmp = NSAllocateCollectable(size, array->zone ? NSScannedOption : 0);
|
||||
#else
|
||||
tmp = NSZoneMalloc(array->zone, size);
|
||||
#endif
|
||||
memcpy(tmp, array->ptr, array->count * sizeof(GSIArrayItem));
|
||||
}
|
||||
else
|
||||
{
|
||||
next = array->cap + array->old;
|
||||
size = next*sizeof(GSIArrayItem);
|
||||
if (_GSIArrayCollector == nil)
|
||||
{
|
||||
tmp = NSZoneRealloc(array->zone, array->ptr, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp = NSReallocateCollectable(array->ptr, size,
|
||||
array->zone ? NSScannedOption : 0);
|
||||
}
|
||||
#if GS_WITH_GC
|
||||
tmp = NSReallocateCollectable(array->ptr, size,
|
||||
array->zone ? NSScannedOption : 0);
|
||||
#else
|
||||
tmp = NSZoneRealloc(array->zone, array->ptr, size);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (tmp == 0)
|
||||
|
@ -245,27 +236,21 @@ GSIArrayGrowTo(GSIArray array, unsigned next)
|
|||
/*
|
||||
* Statically initialised buffer ... copy into new heap buffer.
|
||||
*/
|
||||
if (_GSIArrayCollector == nil)
|
||||
{
|
||||
tmp = NSZoneMalloc(array->zone, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp = NSAllocateCollectable(size, array->zone ? NSScannedOption : 0);
|
||||
}
|
||||
#if GS_WITH_GC
|
||||
tmp = NSAllocateCollectable(size, array->zone ? NSScannedOption : 0);
|
||||
#else
|
||||
tmp = NSZoneMalloc(array->zone, size);
|
||||
#endif
|
||||
memcpy(tmp, array->ptr, array->count * sizeof(GSIArrayItem));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_GSIArrayCollector == nil)
|
||||
{
|
||||
tmp = NSZoneRealloc(array->zone, array->ptr, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp = NSReallocateCollectable(array->ptr, size,
|
||||
array->zone ? NSScannedOption : 0);
|
||||
}
|
||||
#if GS_WITH_GC
|
||||
tmp = NSReallocateCollectable(array->ptr, size,
|
||||
array->zone ? NSScannedOption : 0);
|
||||
#else
|
||||
tmp = NSZoneRealloc(array->zone, array->ptr, size);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (tmp == 0)
|
||||
|
@ -534,6 +519,7 @@ GSIArrayClear(GSIArray array)
|
|||
{
|
||||
if (array->ptr)
|
||||
{
|
||||
#if !GS_WITH_GC
|
||||
/*
|
||||
* Only free memory if it was dynamically initialised (old > 0)
|
||||
*/
|
||||
|
@ -541,6 +527,7 @@ GSIArrayClear(GSIArray array)
|
|||
{
|
||||
NSZoneFree(array->zone, (void*)array->ptr);
|
||||
}
|
||||
#endif
|
||||
array->ptr = 0;
|
||||
array->cap = 0;
|
||||
}
|
||||
|
@ -585,38 +572,19 @@ GSIArrayInitWithZoneAndCapacity(GSIArray array, NSZone *zone, size_t capacity)
|
|||
{
|
||||
unsigned int size;
|
||||
|
||||
if (_GSIArraySetup == NO)
|
||||
{
|
||||
_GSIArrayCollector = [NSGarbageCollector defaultCollector];
|
||||
_GSIArraySetup = YES;
|
||||
}
|
||||
if (_GSIArrayCollector == nil)
|
||||
{
|
||||
array->zone = zone;
|
||||
}
|
||||
else if (zone == GSAtomicMallocZone())
|
||||
{
|
||||
array->zone = (NSZone*)0;
|
||||
}
|
||||
else
|
||||
{
|
||||
array->zone = (NSZone*)1;
|
||||
}
|
||||
array->zone = zone;
|
||||
array->count = 0;
|
||||
if (capacity < 2)
|
||||
capacity = 2;
|
||||
array->cap = capacity;
|
||||
array->old = capacity/2;
|
||||
size = capacity*sizeof(GSIArrayItem);
|
||||
if (_GSIArrayCollector == nil)
|
||||
{
|
||||
array->ptr = (GSIArrayItem*)NSZoneMalloc(zone, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
array->ptr = (GSIArrayItem*)NSAllocateCollectable(size,
|
||||
array->zone ? NSScannedOption : 0);
|
||||
}
|
||||
#if GS_WITH_GC
|
||||
array->ptr = (GSIArrayItem*)NSAllocateCollectable(size,
|
||||
array->zone ? NSScannedOption : 0);
|
||||
#else
|
||||
array->ptr = (GSIArrayItem*)NSZoneMalloc(zone, size);
|
||||
#endif
|
||||
return array;
|
||||
}
|
||||
|
||||
|
@ -624,23 +592,7 @@ static INLINE GSIArray
|
|||
GSIArrayInitWithZoneAndStaticCapacity(GSIArray array, NSZone *zone,
|
||||
size_t capacity, GSIArrayItem *buffer)
|
||||
{
|
||||
if (_GSIArraySetup == NO)
|
||||
{
|
||||
_GSIArrayCollector = [NSGarbageCollector defaultCollector];
|
||||
_GSIArraySetup = YES;
|
||||
}
|
||||
if (_GSIArrayCollector == nil)
|
||||
{
|
||||
array->zone = zone;
|
||||
}
|
||||
else if (zone == GSAtomicMallocZone())
|
||||
{
|
||||
array->zone = (NSZone*)0;
|
||||
}
|
||||
else
|
||||
{
|
||||
array->zone = (NSZone*)1;
|
||||
}
|
||||
array->zone = zone;
|
||||
array->count = 0;
|
||||
array->cap = capacity;
|
||||
array->old = 0;
|
||||
|
@ -654,18 +606,13 @@ GSIArrayCopyWithZone(GSIArray array, NSZone *zone)
|
|||
unsigned int i;
|
||||
GSIArray new;
|
||||
|
||||
if (_GSIArrayCollector == nil)
|
||||
{
|
||||
new = NSZoneMalloc(zone, sizeof(GSIArray_t));
|
||||
GSIArrayInitWithZoneAndCapacity(new, zone, array->count);
|
||||
}
|
||||
else
|
||||
{
|
||||
new = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption);
|
||||
GSIArrayInitWithZoneAndCapacity(new, (zone ? 0 : GSAtomicMallocZone()),
|
||||
array->count);
|
||||
}
|
||||
#if GS_WITH_GC
|
||||
new = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption);
|
||||
#else
|
||||
new = NSZoneMalloc(zone, sizeof(GSIArray_t));
|
||||
#endif
|
||||
|
||||
GSIArrayInitWithZoneAndCapacity(new, zone, array->count);
|
||||
for (i = 0; i < array->count; i++)
|
||||
{
|
||||
GSI_ARRAY_RETAIN(array, array->ptr[i]);
|
||||
|
|
|
@ -81,6 +81,9 @@ extern "C" {
|
|||
* values do not need to be released when the map is emptied.
|
||||
* This permits some optimisation.
|
||||
*
|
||||
* GSI_MAP_NODES()
|
||||
* Define this macro to allocate nodes for the map using typed
|
||||
* memory when working with garbage collection.
|
||||
*/
|
||||
|
||||
#ifndef GSI_MAP_HAS_VALUE
|
||||
|
@ -105,6 +108,10 @@ extern "C" {
|
|||
#ifndef GSI_MAP_EQUAL
|
||||
#define GSI_MAP_EQUAL(M, X, Y) [(X).obj isEqual: (Y).obj]
|
||||
#endif
|
||||
#ifndef GSI_MAP_NODES
|
||||
#define GSI_MAP_NODES(M, X) \
|
||||
(GSIMapNode)NSAllocateCollectable(X*sizeof(GSIMapNode_t), NSScannedOption)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If there is no bitmask defined to supply the types that
|
||||
|
@ -199,16 +206,6 @@ extern "C" {
|
|||
#define GSI_MAP_CLEAR_VAL(node)
|
||||
#endif
|
||||
|
||||
/* Define fake zones to be used for our nodes when GC is in use.
|
||||
*/
|
||||
#define GSIMapStrongKeyAndVal ((NSZone*)0)
|
||||
#define GSIMapWeakKey ((NSZone*)1)
|
||||
#define GSIMapWeakVal ((NSZone*)2)
|
||||
#define GSIMapWeakKeyAndVal ((NSZone*)3)
|
||||
|
||||
static BOOL _GSIMapSetup = NO;
|
||||
static NSGarbageCollector *_collector = nil;
|
||||
|
||||
/*
|
||||
* Description of the datastructure
|
||||
* --------------------------------
|
||||
|
@ -428,30 +425,26 @@ GSIMapMoreNodes(GSIMapTable map, unsigned required)
|
|||
GSIMapNode *newArray;
|
||||
size_t arraySize = (map->chunkCount+1)*sizeof(GSIMapNode);
|
||||
|
||||
/*
|
||||
* Our nodes may be allocated from the atomic zone - but we don't want
|
||||
* them freed - so we must keep the array of pointers to memory chunks in
|
||||
* scanned memory.
|
||||
#if GS_WITH_GC
|
||||
/* We don't want our nodes collected before we have finished with them,
|
||||
* so we must keep the array of pointers to memory chunks in scanned memory.
|
||||
*/
|
||||
if (_collector == nil)
|
||||
{
|
||||
newArray = (GSIMapNode*)NSZoneMalloc(map->zone, arraySize);
|
||||
}
|
||||
else
|
||||
{
|
||||
newArray = (GSIMapNode*)NSAllocateCollectable(arraySize, NSScannedOption);
|
||||
}
|
||||
newArray = (GSIMapNode*)NSAllocateCollectable(arraySize, NSScannedOption);
|
||||
#else
|
||||
newArray = (GSIMapNode*)NSZoneMalloc(map->zone, arraySize);
|
||||
#endif
|
||||
if (newArray)
|
||||
{
|
||||
GSIMapNode newNodes;
|
||||
size_t chunkCount;
|
||||
size_t chunkSize;
|
||||
|
||||
if (map->nodeChunks != 0)
|
||||
{
|
||||
memcpy(newArray, map->nodeChunks,
|
||||
(map->chunkCount)*sizeof(GSIMapNode));
|
||||
#if !GS_WITH_GC
|
||||
NSZoneFree(map->zone, map->nodeChunks);
|
||||
#endif
|
||||
}
|
||||
map->nodeChunks = newArray;
|
||||
|
||||
|
@ -470,17 +463,12 @@ GSIMapMoreNodes(GSIMapTable map, unsigned required)
|
|||
{
|
||||
chunkCount = required;
|
||||
}
|
||||
chunkSize = chunkCount * sizeof(GSIMapNode_t);
|
||||
if (_collector == nil)
|
||||
{
|
||||
newNodes = (GSIMapNode)NSZoneMalloc(map->zone, chunkSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME ... use typed memory for weak pointers.
|
||||
newNodes
|
||||
= (GSIMapNode)NSAllocateCollectable(chunkSize, NSScannedOption);
|
||||
}
|
||||
#if GS_WITH_GC
|
||||
newNodes = GSI_MAP_NODES(map, chunkCount);
|
||||
#else
|
||||
newNodes
|
||||
= (GSIMapNode)NSZoneMalloc(map->zone, chunkCount*sizeof(GSIMapNode_t));
|
||||
#endif
|
||||
if (newNodes)
|
||||
{
|
||||
map->nodeChunks[map->chunkCount++] = newNodes;
|
||||
|
@ -634,34 +622,30 @@ GSIMapResize(GSIMapTable map, size_t new_capacity)
|
|||
size++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Make a new set of buckets for this map
|
||||
#if GS_WITH_GC
|
||||
/* We don't need to use scanned memory because the nodes are not 'owned'
|
||||
* by the bucket they are in, but rather are in chunks pointed to by
|
||||
* the nodeChunks array.
|
||||
*/
|
||||
if (_collector == nil)
|
||||
{
|
||||
/* Use the zone specified for this map.
|
||||
*/
|
||||
new_buckets = (GSIMapBucket)NSZoneCalloc(map->zone, size,
|
||||
sizeof(GSIMapBucket_t));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Use scanned memory so that nodes in each bucket are not collected.
|
||||
* FIXME ... should use typed memory as the node count of each
|
||||
* bucket does not need to be scanned.
|
||||
*/
|
||||
new_buckets = (GSIMapBucket)NSAllocateCollectable
|
||||
(size * sizeof(GSIMapBucket_t), NSScannedOption);
|
||||
}
|
||||
new_buckets = (GSIMapBucket)NSAllocateCollectable
|
||||
(size * sizeof(GSIMapBucket_t), 0);
|
||||
#else
|
||||
/* Use the zone specified for this map.
|
||||
*/
|
||||
new_buckets = (GSIMapBucket)NSZoneCalloc(map->zone, size,
|
||||
sizeof(GSIMapBucket_t));
|
||||
#endif
|
||||
|
||||
if (new_buckets != 0)
|
||||
{
|
||||
GSIMapRemangleBuckets(map, map->buckets, map->bucketCount, new_buckets,
|
||||
size);
|
||||
|
||||
#if !GS_WITH_GC
|
||||
if (map->buckets != 0)
|
||||
{
|
||||
NSZoneFree(map->zone, map->buckets);
|
||||
}
|
||||
#endif
|
||||
map->buckets = new_buckets;
|
||||
map->bucketCount = size;
|
||||
}
|
||||
|
@ -914,8 +898,6 @@ GSIMapCleanMap(GSIMapTable map)
|
|||
static INLINE void
|
||||
GSIMapEmptyMap(GSIMapTable map)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
#ifdef GSI_MAP_NOCLEAN
|
||||
if (GSI_MAP_NOCLEAN)
|
||||
{
|
||||
|
@ -930,53 +912,34 @@ GSIMapEmptyMap(GSIMapTable map)
|
|||
#endif
|
||||
if (map->buckets != 0)
|
||||
{
|
||||
#if !GS_WITH_GC
|
||||
NSZoneFree(map->zone, map->buckets);
|
||||
#endif
|
||||
map->buckets = 0;
|
||||
map->bucketCount = 0;
|
||||
}
|
||||
if (map->nodeChunks != 0)
|
||||
{
|
||||
#if !GS_WITH_GC
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < map->chunkCount; i++)
|
||||
{
|
||||
NSZoneFree(map->zone, map->nodeChunks[i]);
|
||||
}
|
||||
map->chunkCount = 0;
|
||||
NSZoneFree(map->zone, map->nodeChunks);
|
||||
#endif
|
||||
map->chunkCount = 0;
|
||||
map->nodeChunks = 0;
|
||||
}
|
||||
map->freeNodes = 0;
|
||||
map->zone = 0;
|
||||
}
|
||||
|
||||
static inline void
|
||||
GSIMapSetup()
|
||||
{
|
||||
if (_GSIMapSetup == NO)
|
||||
{
|
||||
_collector = [NSGarbageCollector defaultCollector];
|
||||
_GSIMapSetup = YES;
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
GSIMapInitWithZoneAndCapacity(GSIMapTable map, NSZone *zone, size_t capacity)
|
||||
{
|
||||
GSIMapSetup();
|
||||
if (_collector != nil && (uintptr_t)zone > 3)
|
||||
{
|
||||
if (zone == GSAtomicMallocZone())
|
||||
{
|
||||
map->zone = GSIMapWeakKeyAndVal; // Unscanned memory
|
||||
}
|
||||
else
|
||||
{
|
||||
map->zone = GSIMapStrongKeyAndVal; // Scanned memory
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
map->zone = zone;
|
||||
}
|
||||
map->zone = zone;
|
||||
map->nodeCount = 0;
|
||||
map->bucketCount = 0;
|
||||
map->buckets = 0;
|
||||
|
|
|
@ -223,13 +223,6 @@ NSZoneStats (NSZone *zone);
|
|||
void*
|
||||
GSOutOfMemory(NSUInteger size, BOOL retry);
|
||||
|
||||
/**
|
||||
* Returns the default zone used for memory allocation, created at startup.
|
||||
* This zone cannot be recycled.
|
||||
*/
|
||||
GS_EXPORT NSZone*
|
||||
GSAtomicMallocZone (void);
|
||||
|
||||
/**
|
||||
* Called during +initialize to tell the class that instances created
|
||||
* in future should have the specified instance variable as a weak
|
||||
|
@ -300,11 +293,12 @@ enum {
|
|||
/** Allocate memory. If garbage collection is not enabled this uses the
|
||||
* default malloc zone and the options are ignored.<br />
|
||||
* If garbage collection is enabled, the allocate memory is normally not
|
||||
* scanned for pointers but is isttself garbage collectable. The options
|
||||
* scanned for pointers but is itsself garbage collectable. The options
|
||||
* argument is a bitmask in which NSScannedOption sets the memory to be
|
||||
* scanned for pointers by the garbage collector, and
|
||||
* NSCollectorDisabledOption causes the memory to be excempt from being
|
||||
* garbage collected itsself.
|
||||
* garbage collected itsself.<br />
|
||||
* In any case the memory returned is zero'ed.
|
||||
*/
|
||||
GS_EXPORT void *
|
||||
NSAllocateCollectable(NSUInteger size, NSUInteger options);
|
||||
|
|
|
@ -159,11 +159,7 @@ static SEL objSel;
|
|||
[aCoder decodeValueOfObjCType: @encode(unsigned)
|
||||
at: &count];
|
||||
|
||||
#if GS_WITH_GC
|
||||
GSIMapInitWithZoneAndCapacity(&map, GSIMapStrongKeyAndVal, count);
|
||||
#else
|
||||
GSIMapInitWithZoneAndCapacity(&map, GSObjCZone(self), count);
|
||||
#endif
|
||||
while (count-- > 0)
|
||||
{
|
||||
(*imp)(aCoder, sel, type, &key);
|
||||
|
@ -179,12 +175,7 @@ static SEL objSel;
|
|||
{
|
||||
unsigned int i;
|
||||
|
||||
#if GS_WITH_GC
|
||||
GSIMapInitWithZoneAndCapacity(&map, GSIMapStrongKeyAndVal, c);
|
||||
#else
|
||||
GSIMapInitWithZoneAndCapacity(&map, GSObjCZone(self), c);
|
||||
#endif
|
||||
|
||||
for (i = 0; i < c; i++)
|
||||
{
|
||||
GSIMapNode node;
|
||||
|
@ -226,12 +217,7 @@ static SEL objSel;
|
|||
NSZone *z = GSObjCZone(self);
|
||||
unsigned c = [other count];
|
||||
|
||||
#if GS_WITH_GC
|
||||
GSIMapInitWithZoneAndCapacity(&map, GSIMapStrongKeyAndVal, c);
|
||||
#else
|
||||
GSIMapInitWithZoneAndCapacity(&map, z, c);
|
||||
#endif
|
||||
|
||||
if (c > 0)
|
||||
{
|
||||
NSEnumerator *e = [other keyEnumerator];
|
||||
|
@ -382,11 +368,7 @@ static SEL objSel;
|
|||
/* Designated initialiser */
|
||||
- (id) initWithCapacity: (unsigned)cap
|
||||
{
|
||||
#if GS_WITH_GC
|
||||
GSIMapInitWithZoneAndCapacity(&map, GSIMapStrongKeyAndVal, cap);
|
||||
#else
|
||||
GSIMapInitWithZoneAndCapacity(&map, GSObjCZone(self), cap);
|
||||
#endif
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -771,6 +771,63 @@ GSUnicode(const unichar *chars, unsigned length,
|
|||
return i;
|
||||
}
|
||||
|
||||
#if GS_WITH_GC
|
||||
|
||||
#define GROW() \
|
||||
if (dst == 0) \
|
||||
{ \
|
||||
/* \
|
||||
* Data is just being discarded anyway, so we can \
|
||||
* reset the offset into the local buffer on the \
|
||||
* stack and pretend the buffer has grown. \
|
||||
*/ \
|
||||
ptr = buf - dpos; \
|
||||
bsize = dpos + BUFSIZ; \
|
||||
if (extra != 0) \
|
||||
{ \
|
||||
bsize--; \
|
||||
} \
|
||||
} \
|
||||
else if (zone == 0) \
|
||||
{ \
|
||||
result = NO; /* No buffer growth possible ... fail. */ \
|
||||
goto done; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
unsigned grow = slen; \
|
||||
\
|
||||
if (grow < bsize + BUFSIZ) \
|
||||
{ \
|
||||
grow = bsize + BUFSIZ; \
|
||||
} \
|
||||
grow *= sizeof(unichar); \
|
||||
\
|
||||
if (ptr == buf || ptr == *dst) \
|
||||
{ \
|
||||
unichar *tmp; \
|
||||
\
|
||||
tmp = NSAllocateCollectable(grow + extra, 0); \
|
||||
if (tmp != 0) \
|
||||
{ \
|
||||
memcpy(tmp, ptr, bsize * sizeof(unichar)); \
|
||||
} \
|
||||
ptr = tmp; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
ptr = NSReallocateCollectable(ptr, grow + extra, 0); \
|
||||
} \
|
||||
if (ptr == 0) \
|
||||
{ \
|
||||
result = NO; /* Not enough memory */ \
|
||||
break; \
|
||||
} \
|
||||
bsize = grow / sizeof(unichar); \
|
||||
}
|
||||
|
||||
#else /* GS_WITH_GC */
|
||||
|
||||
#define GROW() \
|
||||
if (dst == 0) \
|
||||
{ \
|
||||
|
@ -824,6 +881,8 @@ else \
|
|||
bsize = grow / sizeof(unichar); \
|
||||
}
|
||||
|
||||
#endif /* GS_WITH_GC */
|
||||
|
||||
/**
|
||||
* Function to convert from 8-bit data to 16-bit unicode characters.
|
||||
* <p>The dst argument is a pointer to a pointer to a buffer in which the
|
||||
|
@ -852,7 +911,10 @@ else \
|
|||
* allocate a buffer to return data in.
|
||||
* If this is nul, the function will fail if the originally supplied buffer
|
||||
* is not big enough (unless dst is a null pointer ... indicating that
|
||||
* converted data is to be discarded).
|
||||
* converted data is to be discarded).<br />
|
||||
* If the library is built for garbage collecting, the zone argument is used
|
||||
* only as a marker to say whether the function may allocate memory (zone
|
||||
* is non-null) or not (zone is null).
|
||||
* </p>
|
||||
* The options argument controls some special behavior.
|
||||
* <list>
|
||||
|
@ -1234,12 +1296,17 @@ done:
|
|||
/*
|
||||
* Temporary string was requested ... make one.
|
||||
*/
|
||||
#if GS_WITH_GC
|
||||
r = NSAllocateCollectable(bytes, 0);
|
||||
memcpy(r, ptr, bytes);
|
||||
#else
|
||||
r = GSAutoreleasedBuffer(bytes);
|
||||
memcpy(r, ptr, bytes);
|
||||
if (ptr != buf && (dst == 0 || ptr != *dst))
|
||||
{
|
||||
NSZoneFree(zone, ptr);
|
||||
}
|
||||
#endif
|
||||
ptr = r;
|
||||
*dst = ptr;
|
||||
}
|
||||
|
@ -1255,7 +1322,11 @@ done:
|
|||
{
|
||||
unichar *tmp;
|
||||
|
||||
#if GS_WITH_GC
|
||||
tmp = NSAllocateCollectable(bytes, 0);
|
||||
#else
|
||||
tmp = NSZoneMalloc(zone, bytes);
|
||||
#endif
|
||||
if (tmp != 0)
|
||||
{
|
||||
memcpy(tmp, ptr, bytes);
|
||||
|
@ -1264,7 +1335,11 @@ done:
|
|||
}
|
||||
else
|
||||
{
|
||||
#if GS_WITH_GC
|
||||
ptr = NSReallocateCollectable(ptr, bytes, 0);
|
||||
#else
|
||||
ptr = NSZoneRealloc(zone, ptr, bytes);
|
||||
#endif
|
||||
}
|
||||
*dst = ptr;
|
||||
}
|
||||
|
@ -1278,10 +1353,12 @@ done:
|
|||
*dst = ptr;
|
||||
}
|
||||
}
|
||||
#if !GS_WITH_GC
|
||||
else if (ptr != buf && dst != 0 && ptr != *dst)
|
||||
{
|
||||
NSZoneFree(zone, ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (dst)
|
||||
NSCAssert(*dst != buf, @"attempted to pass out pointer to internal buffer");
|
||||
|
@ -1292,6 +1369,62 @@ done:
|
|||
#undef GROW
|
||||
|
||||
|
||||
#if GS_WITH_GC
|
||||
|
||||
#define GROW() \
|
||||
if (dst == 0) \
|
||||
{ \
|
||||
/* \
|
||||
* Data is just being discarded anyway, so we can \
|
||||
* reset the offset into the local buffer on the \
|
||||
* stack and pretend the buffer has grown. \
|
||||
*/ \
|
||||
ptr = buf - dpos; \
|
||||
bsize = dpos + BUFSIZ; \
|
||||
if (extra != 0) \
|
||||
{ \
|
||||
bsize--; \
|
||||
} \
|
||||
} \
|
||||
else if (zone == 0) \
|
||||
{ \
|
||||
result = NO; /* No buffer growth possible ... fail. */ \
|
||||
goto done; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
unsigned grow = slen; \
|
||||
\
|
||||
if (grow < bsize + BUFSIZ) \
|
||||
{ \
|
||||
grow = bsize + BUFSIZ; \
|
||||
} \
|
||||
\
|
||||
if (ptr == buf || ptr == *dst) \
|
||||
{ \
|
||||
unsigned char *tmp; \
|
||||
\
|
||||
tmp = NSAllocateCollectable(grow + extra, 0); \
|
||||
if (tmp != 0) \
|
||||
{ \
|
||||
memcpy(tmp, ptr, bsize); \
|
||||
} \
|
||||
ptr = tmp; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
ptr = NSReallocateCollectable(ptr, grow + extra, 0); \
|
||||
} \
|
||||
if (ptr == 0) \
|
||||
{ \
|
||||
result = NO; /* Not enough memory */ \
|
||||
break; \
|
||||
} \
|
||||
bsize = grow; \
|
||||
}
|
||||
|
||||
#else /* GS_WITH_GC */
|
||||
|
||||
#define GROW() \
|
||||
if (dst == 0) \
|
||||
{ \
|
||||
|
@ -1344,6 +1477,7 @@ else \
|
|||
bsize = grow; \
|
||||
}
|
||||
|
||||
#endif /* GS_WITH_GC */
|
||||
|
||||
static inline int chop(unichar c, _ucc_ *table, int hi)
|
||||
{
|
||||
|
@ -1397,7 +1531,10 @@ static inline int chop(unichar c, _ucc_ *table, int hi)
|
|||
* allocate a buffer to return data in.
|
||||
* If this is nul, the function will fail if the originally supplied buffer
|
||||
* is not big enough (unless dst is a null pointer ... indicating that
|
||||
* converted data is to be discarded).
|
||||
* converted data is to be discarded).<br />
|
||||
* If the library is built for garbage collecting, the zone argument is used
|
||||
* only as a marker to say whether the function may allocate memory (zone
|
||||
* is non-null) or not (zone is null).
|
||||
* </p>
|
||||
* The options argument controls some special behavior.
|
||||
* <list>
|
||||
|
@ -1969,12 +2106,17 @@ iconv_start:
|
|||
/*
|
||||
* Temporary string was requested ... make one.
|
||||
*/
|
||||
#if GS_WITH_GC
|
||||
r = NSAllocateCollectable(bytes, 0);
|
||||
memcpy(r, ptr, bytes);
|
||||
#else
|
||||
r = GSAutoreleasedBuffer(bytes);
|
||||
memcpy(r, ptr, bytes);
|
||||
if (ptr != buf && (dst == 0 || ptr != *dst))
|
||||
{
|
||||
NSZoneFree(zone, ptr);
|
||||
}
|
||||
#endif
|
||||
ptr = r;
|
||||
*dst = ptr;
|
||||
}
|
||||
|
@ -1990,7 +2132,11 @@ iconv_start:
|
|||
{
|
||||
unsigned char *tmp;
|
||||
|
||||
#if GS_WITH_GC
|
||||
tmp = NSAllocateCollectable(bytes, 0);
|
||||
#else
|
||||
tmp = NSZoneMalloc(zone, bytes);
|
||||
#endif
|
||||
if (tmp != 0)
|
||||
{
|
||||
memcpy(tmp, ptr, bytes);
|
||||
|
@ -1999,7 +2145,11 @@ iconv_start:
|
|||
}
|
||||
else
|
||||
{
|
||||
#if GS_WITH_GC
|
||||
ptr = NSReallocateCollectable(ptr, bytes, 0);
|
||||
#else
|
||||
ptr = NSZoneRealloc(zone, ptr, bytes);
|
||||
#endif
|
||||
}
|
||||
*dst = ptr;
|
||||
}
|
||||
|
@ -2013,10 +2163,12 @@ iconv_start:
|
|||
*dst = ptr;
|
||||
}
|
||||
}
|
||||
#if !GS_WITH_GC
|
||||
else if (ptr != buf && dst != 0 && ptr != *dst)
|
||||
{
|
||||
NSZoneFree(zone, ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (dst)
|
||||
NSCAssert(*dst != buf, @"attempted to pass out pointer to internal buffer");
|
||||
|
|
|
@ -105,6 +105,13 @@ static NSDictionary *blank;
|
|||
#define GSI_MAP_VTYPES GSUNION_INT
|
||||
#define GSI_MAP_NOCLEAN 1
|
||||
|
||||
#if GS_WITH_GC
|
||||
#include <gc_typed.h>
|
||||
static GC_descr nodeDesc; // Type descriptor for map node.
|
||||
#define GSI_MAP_NODES(M, X) \
|
||||
(GSIMapNode)GC_calloc_explicitly_typed(X, sizeof(GSIMapNode_t), nodeDesc)
|
||||
#endif
|
||||
|
||||
#include "GNUstepBase/GSIMap.h"
|
||||
|
||||
static NSLock *attrLock = nil;
|
||||
|
@ -276,10 +283,14 @@ static void _setup(void)
|
|||
NSDictionary *d;
|
||||
|
||||
#if GS_WITH_GC
|
||||
GSIMapInitWithZoneAndCapacity(&attrMap, GSIMapStrongKeyAndVal, 32);
|
||||
#else
|
||||
GSIMapInitWithZoneAndCapacity(&attrMap, NSDefaultMallocZone(), 32);
|
||||
/* We create a typed memory descriptor for map nodes.
|
||||
* Only the pointer to the key needs to be scanned.
|
||||
*/
|
||||
GC_word w[GC_BITMAP_SIZE(GSIMapNode_t)] = {0};
|
||||
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, key));
|
||||
nodeDesc = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
|
||||
#endif
|
||||
GSIMapInitWithZoneAndCapacity(&attrMap, NSDefaultMallocZone(), 32);
|
||||
|
||||
infSel = @selector(newWithZone:value:at:);
|
||||
addSel = @selector(addObject:);
|
||||
|
|
|
@ -37,6 +37,13 @@
|
|||
#define GSI_MAP_KTYPES GSUNION_OBJ
|
||||
#define GSI_MAP_VTYPES GSUNION_INT
|
||||
|
||||
#if GS_WITH_GC
|
||||
#include <gc_typed.h>
|
||||
static GC_descr nodeDesc; // Type descriptor for map node.
|
||||
#define GSI_MAP_NODES(M, X) \
|
||||
(GSIMapNode)GC_calloc_explicitly_typed(X, sizeof(GSIMapNode_t), nodeDesc)
|
||||
#endif
|
||||
|
||||
#include "GNUstepBase/GSIMap.h"
|
||||
|
||||
@interface GSCountedSet : NSCountedSet
|
||||
|
@ -93,6 +100,14 @@
|
|||
{
|
||||
if (self == [GSCountedSet class])
|
||||
{
|
||||
#if GS_WITH_GC
|
||||
/* We create a typed memory descriptor for map nodes.
|
||||
* Only the pointer to the key needs to be scanned.
|
||||
*/
|
||||
GC_word w[GC_BITMAP_SIZE(GSIMapNode_t)] = {0};
|
||||
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, key));
|
||||
nodeDesc = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,11 +198,7 @@
|
|||
/* Designated initialiser */
|
||||
- (id) initWithCapacity: (unsigned)cap
|
||||
{
|
||||
#if GS_WITH_GC
|
||||
GSIMapInitWithZoneAndCapacity(&map, GSIMapStrongKeyAndVal, cap);
|
||||
#else
|
||||
GSIMapInitWithZoneAndCapacity(&map, [self zone], cap);
|
||||
#endif
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -203,11 +214,7 @@
|
|||
|
||||
(*imp)(aCoder, sel, utype, &count);
|
||||
|
||||
#if GS_WITH_GC
|
||||
GSIMapInitWithZoneAndCapacity(&map, GSIMapStrongKeyAndVal, count);
|
||||
#else
|
||||
GSIMapInitWithZoneAndCapacity(&map, [self zone], count);
|
||||
#endif
|
||||
while (count-- > 0)
|
||||
{
|
||||
(*imp)(aCoder, sel, otype, &value);
|
||||
|
|
|
@ -47,6 +47,13 @@
|
|||
#define GSI_MAP_RETAIN_KEY(M, X) ((X).obj) = \
|
||||
[((id)(X).obj) copyWithZone: map->zone]
|
||||
|
||||
#if GS_WITH_GC
|
||||
#include <gc_typed.h>
|
||||
static GC_descr nodeDesc; // Type descriptor for map node.
|
||||
#define GSI_MAP_NODES(M, X) \
|
||||
(GSIMapNode)GC_calloc_explicitly_typed(X, sizeof(GSIMapNode_t), nodeDesc)
|
||||
#endif
|
||||
|
||||
#include "GNUstepBase/GSIMap.h"
|
||||
|
||||
@interface GSDictionary : NSDictionary
|
||||
|
@ -82,6 +89,15 @@ static SEL objSel;
|
|||
{
|
||||
if (self == [GSDictionary class])
|
||||
{
|
||||
#if GS_WITH_GC
|
||||
/* We create a typed memory descriptor for map nodes.
|
||||
* The pointers to the key and value need to be scanned.
|
||||
*/
|
||||
GC_word w[GC_BITMAP_SIZE(GSIMapNode_t)] = {0};
|
||||
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, key));
|
||||
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, value));
|
||||
nodeDesc = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
|
||||
#endif
|
||||
nxtSel = @selector(nextObject);
|
||||
objSel = @selector(objectForKey:);
|
||||
}
|
||||
|
@ -156,11 +172,7 @@ static SEL objSel;
|
|||
[aCoder decodeValueOfObjCType: @encode(unsigned)
|
||||
at: &count];
|
||||
|
||||
#if GS_WITH_GC
|
||||
GSIMapInitWithZoneAndCapacity(&map, GSIMapStrongKeyAndVal, count);
|
||||
#else
|
||||
GSIMapInitWithZoneAndCapacity(&map, GSObjCZone(self), count);
|
||||
#endif
|
||||
while (count-- > 0)
|
||||
{
|
||||
(*imp)(aCoder, sel, type, &key);
|
||||
|
@ -176,11 +188,7 @@ static SEL objSel;
|
|||
{
|
||||
unsigned int i;
|
||||
|
||||
#if GS_WITH_GC
|
||||
GSIMapInitWithZoneAndCapacity(&map, GSIMapStrongKeyAndVal, c);
|
||||
#else
|
||||
GSIMapInitWithZoneAndCapacity(&map, GSObjCZone(self), c);
|
||||
#endif
|
||||
for (i = 0; i < c; i++)
|
||||
{
|
||||
GSIMapNode node;
|
||||
|
@ -222,12 +230,7 @@ static SEL objSel;
|
|||
NSZone *z = GSObjCZone(self);
|
||||
unsigned c = [other count];
|
||||
|
||||
#if GS_WITH_GC
|
||||
GSIMapInitWithZoneAndCapacity(&map, GSIMapStrongKeyAndVal, c);
|
||||
#else
|
||||
GSIMapInitWithZoneAndCapacity(&map, z, c);
|
||||
#endif
|
||||
|
||||
if (c > 0)
|
||||
{
|
||||
NSEnumerator *e = [other keyEnumerator];
|
||||
|
@ -378,11 +381,7 @@ static SEL objSel;
|
|||
/* Designated initialiser */
|
||||
- (id) initWithCapacity: (unsigned)cap
|
||||
{
|
||||
#if GS_WITH_GC
|
||||
GSIMapInitWithZoneAndCapacity(&map, GSIMapStrongKeyAndVal, cap);
|
||||
#else
|
||||
GSIMapInitWithZoneAndCapacity(&map, GSObjCZone(self), cap);
|
||||
#endif
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -514,5 +514,8 @@ GSPrivateUnloadModule(FILE *errorStream,
|
|||
- (void) protect;
|
||||
@end
|
||||
|
||||
NSZone*
|
||||
GSAtomicMallocZone (void);
|
||||
|
||||
#endif /* _GSPrivate_h_ */
|
||||
|
||||
|
|
|
@ -40,6 +40,13 @@
|
|||
|
||||
#define GSI_MAP_HAS_VALUE 0
|
||||
#define GSI_MAP_KTYPES GSUNION_OBJ
|
||||
#if GS_WITH_GC
|
||||
#include <gc_typed.h>
|
||||
static GC_descr nodeDesc; // Type descriptor for map node.
|
||||
#define GSI_MAP_NODES(M, X) \
|
||||
(GSIMapNode)GC_calloc_explicitly_typed(X, sizeof(GSIMapNode_t), nodeDesc)
|
||||
#endif
|
||||
|
||||
|
||||
#include "GNUstepBase/GSIMap.h"
|
||||
|
||||
|
@ -114,6 +121,14 @@ static Class mutableSetClass;
|
|||
setClass = [GSSet class];
|
||||
mutableSetClass = [GSMutableSet class];
|
||||
memberSel = @selector(member:);
|
||||
#if GS_WITH_GC
|
||||
/* We create a typed memory descriptor for map nodes.
|
||||
* Only the pointer to the key needs to be scanned.
|
||||
*/
|
||||
GC_word w[GC_BITMAP_SIZE(GSIMapNode_t)] = {0};
|
||||
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, key));
|
||||
nodeDesc = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -227,11 +242,7 @@ static Class mutableSetClass;
|
|||
|
||||
(*imp)(aCoder, sel, @encode(unsigned), &count);
|
||||
|
||||
#if GS_WITH_GC
|
||||
GSIMapInitWithZoneAndCapacity(&map, GSIMapStrongKeyAndVal, count);
|
||||
#else
|
||||
GSIMapInitWithZoneAndCapacity(&map, [self zone], count);
|
||||
#endif
|
||||
while (count-- > 0)
|
||||
{
|
||||
(*imp)(aCoder, sel, type, &value);
|
||||
|
@ -246,11 +257,7 @@ static Class mutableSetClass;
|
|||
{
|
||||
unsigned i;
|
||||
|
||||
#if GS_WITH_GC
|
||||
GSIMapInitWithZoneAndCapacity(&map, GSIMapStrongKeyAndVal, c);
|
||||
#else
|
||||
GSIMapInitWithZoneAndCapacity(&map, [self zone], c);
|
||||
#endif
|
||||
for (i = 0; i < c; i++)
|
||||
{
|
||||
GSIMapNode node;
|
||||
|
@ -584,11 +591,7 @@ static Class mutableSetClass;
|
|||
/* Designated initialiser */
|
||||
- (id) initWithCapacity: (unsigned)cap
|
||||
{
|
||||
#if GS_WITH_GC
|
||||
GSIMapInitWithZoneAndCapacity(&map, GSIMapStrongKeyAndVal, cap);
|
||||
#else
|
||||
GSIMapInitWithZoneAndCapacity(&map, [self zone], cap);
|
||||
#endif
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,11 @@
|
|||
#define GSI_MAP_HASH(M, X) ((X).uint)
|
||||
#define GSI_MAP_EQUAL(M, X,Y) ((X).ptr == (Y).ptr)
|
||||
#define GSI_MAP_NOCLEAN 1
|
||||
#if GS_WITH_GC
|
||||
#define GSI_MAP_NODES(M, X) \
|
||||
(GSIMapNode)NSAllocateCollectable(X * sizeof(GSIMapNode_t), 0)
|
||||
#endif
|
||||
|
||||
|
||||
#include "GNUstepBase/GSIMap.h"
|
||||
|
||||
|
@ -138,9 +143,11 @@ static Class NSMutableDataMallocClass;
|
|||
* Set up map tables.
|
||||
*/
|
||||
#if GS_WITH_GC
|
||||
zone = GSIMapStrongKeyAndVal;
|
||||
#endif
|
||||
_clsMap = (GSIMapTable)NSAllocateCollectable(sizeof(GSIMapTable_t)*6,
|
||||
NSScannedOption);
|
||||
#else
|
||||
_clsMap = (GSIMapTable)NSZoneMalloc(zone, sizeof(GSIMapTable_t)*6);
|
||||
#endif
|
||||
_cIdMap = &_clsMap[1];
|
||||
_uIdMap = &_clsMap[2];
|
||||
_ptrMap = &_clsMap[3];
|
||||
|
|
|
@ -48,6 +48,14 @@
|
|||
#define GSI_MAP_HASH(M, X) ((X).uint ^ ((X).uint >> 3))
|
||||
#define GSI_MAP_EQUAL(M, X,Y) ((X).ptr == (Y).ptr)
|
||||
#define GSI_MAP_NOCLEAN 1
|
||||
#if GS_WITH_GC
|
||||
// FIXME ...
|
||||
#include <gc_typed.h>
|
||||
static GC_descr nodeDesc; // Type descriptor for map node.
|
||||
#define GSI_MAP_NODES(M, X) \
|
||||
(GSIMapNode)GC_calloc_explicitly_typed(X, sizeof(GSIMapNode_t), nodeDesc)
|
||||
#endif
|
||||
|
||||
|
||||
#include "GNUstepBase/GSIMap.h"
|
||||
|
||||
|
@ -546,6 +554,16 @@ static NSLock *cached_proxies_gate = nil;
|
|||
NSNotificationCenter *nc;
|
||||
|
||||
GSMakeWeakPointer(self, "delegate");
|
||||
|
||||
#if GS_WITH_GC
|
||||
/* We create a typed memory descriptor for map nodes.
|
||||
* FIXME
|
||||
*/
|
||||
GC_word w[GC_BITMAP_SIZE(GSIMapNode_t)] = {0};
|
||||
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, key));
|
||||
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, value));
|
||||
nodeDesc = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
|
||||
#endif
|
||||
connectionClass = self;
|
||||
dateClass = [NSDate class];
|
||||
distantObjectClass = [NSDistantObject class];
|
||||
|
@ -949,14 +967,16 @@ static NSLock *cached_proxies_gate = nil;
|
|||
*/
|
||||
_requestQueue = [NSMutableArray new];
|
||||
|
||||
#if GS_WITH_GC
|
||||
z = GSIMapStrongKeyAndVal;
|
||||
#endif
|
||||
/*
|
||||
* This maps request sequence numbers to the NSPortCoder objects representing
|
||||
* replies arriving from the remote connection.
|
||||
*/
|
||||
#if GS_WITH_GC
|
||||
_replyMap = (GSIMapTable)NSAllocateCollectable(sizeof(GSIMapTable_t),
|
||||
NSScannedOption);
|
||||
#else
|
||||
_replyMap = (GSIMapTable)NSZoneMalloc(z, sizeof(GSIMapTable_t));
|
||||
#endif
|
||||
GSIMapInitWithZoneAndCapacity(_replyMap, z, 4);
|
||||
|
||||
/*
|
||||
|
@ -964,19 +984,34 @@ static NSLock *cached_proxies_gate = nil;
|
|||
* We use this instead of an NSHashTable because we only care about
|
||||
* the object's address, and don't want to send the -hash message to it.
|
||||
*/
|
||||
#if GS_WITH_GC
|
||||
_localObjects= (GSIMapTable)NSAllocateCollectable(sizeof(GSIMapTable_t),
|
||||
NSScannedOption);
|
||||
#else
|
||||
_localObjects = (GSIMapTable)NSZoneMalloc(z, sizeof(GSIMapTable_t));
|
||||
#endif
|
||||
GSIMapInitWithZoneAndCapacity(_localObjects, z, 4);
|
||||
|
||||
/*
|
||||
* This maps handles for local objects to their local proxies.
|
||||
*/
|
||||
#if GS_WITH_GC
|
||||
_localTargets = (GSIMapTable)NSAllocateCollectable(sizeof(GSIMapTable_t),
|
||||
NSScannedOption);
|
||||
#else
|
||||
_localTargets = (GSIMapTable)NSZoneMalloc(z, sizeof(GSIMapTable_t));
|
||||
#endif
|
||||
GSIMapInitWithZoneAndCapacity(_localTargets, z, 4);
|
||||
|
||||
/*
|
||||
* This maps targets to remote proxies.
|
||||
*/
|
||||
#if GS_WITH_GC
|
||||
_remoteProxies = (GSIMapTable)NSAllocateCollectable(sizeof(GSIMapTable_t),
|
||||
NSScannedOption);
|
||||
#else
|
||||
_remoteProxies = (GSIMapTable)NSZoneMalloc(z, sizeof(GSIMapTable_t));
|
||||
#endif
|
||||
GSIMapInitWithZoneAndCapacity(_remoteProxies, z, 4);
|
||||
|
||||
_requestDepth = 0;
|
||||
|
|
|
@ -57,8 +57,32 @@
|
|||
(M->extra.retain)((NSHashTable*)M, X.ptr)
|
||||
#define GSI_MAP_ENUMERATOR NSHashEnumerator
|
||||
|
||||
#if GS_WITH_GC
|
||||
#include <gc_typed.h>
|
||||
static GC_descr nodeStrong = 0;
|
||||
static GC_descr nodeWeak = 0;
|
||||
#define GSI_MAP_NODES(M, X) (GSIMapNode)GC_calloc_explicitly_typed(X, sizeof(GSIMapNode_t), (GC_descr)M->zone)
|
||||
#endif
|
||||
|
||||
#include "GNUstepBase/GSIMap.h"
|
||||
|
||||
#if GS_WITH_GC
|
||||
static inline void
|
||||
initialize()
|
||||
{
|
||||
if (nodeStrong == 0)
|
||||
{
|
||||
/* We create a typed memory descriptor for map nodes.
|
||||
* Only the pointer to the key needs to be scanned.
|
||||
*/
|
||||
GC_word w[GC_BITMAP_SIZE(GSIMapNode_t)] = {0};
|
||||
nodeWeak = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
|
||||
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, key));
|
||||
nodeStrong = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns an array of all the objects in the table.
|
||||
* NB. The table <em>must</em> contain objects, not pointers or integers.
|
||||
|
@ -156,9 +180,9 @@ NSCopyHashTableWithZone(NSHashTable *table, NSZone *zone)
|
|||
}
|
||||
|
||||
#if GS_WITH_GC
|
||||
zone = GSIMapStrongKeyAndVal;
|
||||
t = (GSIMapTable)NSAllocateCollectable(sizeof(GSIMapTable_t),
|
||||
NSScannedOption);
|
||||
zone = ((GSIMapTable)table)->zone;
|
||||
#else
|
||||
t = (GSIMapTable)NSZoneMalloc(zone, sizeof(GSIMapTable_t));
|
||||
#endif
|
||||
|
@ -220,9 +244,10 @@ NSCreateHashTableWithZone(
|
|||
GSIMapTable table;
|
||||
|
||||
#if GS_WITH_GC
|
||||
zone = GSIMapStrongKeyAndVal;
|
||||
initialize();
|
||||
table = (GSIMapTable)NSAllocateCollectable(sizeof(GSIMapTable_t),
|
||||
NSScannedOption);
|
||||
zone = (NSZone*)nodeStrong;
|
||||
#else
|
||||
table = (GSIMapTable)NSZoneMalloc(zone, sizeof(GSIMapTable_t));
|
||||
#endif
|
||||
|
|
|
@ -37,13 +37,23 @@
|
|||
/*
|
||||
* Setup for inline operation of pointer map tables.
|
||||
*/
|
||||
#define GSI_MAP_RETAIN_KEY(M, X) RETAIN(X.obj)
|
||||
#define GSI_MAP_RELEASE_KEY(M, X) RELEASE(X.obj)
|
||||
#define GSI_MAP_RETAIN_VAL(M, X)
|
||||
#define GSI_MAP_RELEASE_VAL(M, X)
|
||||
#define GSI_MAP_HASH(M, X) ((X).uint)
|
||||
#define GSI_MAP_EQUAL(M, X,Y) ((X).ptr == (Y).ptr)
|
||||
#undef GSI_MAP_NOCLEAN
|
||||
#if GS_WITH_GC
|
||||
#include <gc_typed.h>
|
||||
static GC_descr nodeDesc; // Type descriptor for map node.
|
||||
#define GSI_MAP_NODES(M, X) \
|
||||
(GSIMapNode)GC_calloc_explicitly_typed(X, sizeof(GSIMapNode_t), nodeDesc)
|
||||
#define GSI_MAP_RETAIN_KEY(M, X)
|
||||
#define GSI_MAP_RELEASE_KEY(M, X)
|
||||
#else
|
||||
#define GSI_MAP_RETAIN_KEY(M, X) RETAIN(X.obj)
|
||||
#define GSI_MAP_RELEASE_KEY(M, X) RELEASE(X.obj)
|
||||
#endif
|
||||
|
||||
|
||||
#include "GNUstepBase/GSIMap.h"
|
||||
|
||||
|
@ -473,6 +483,14 @@ static NSDictionary *makeReference(unsigned ref)
|
|||
{
|
||||
GSMakeWeakPointer(self, "delegate");
|
||||
|
||||
#if GS_WITH_GC
|
||||
/* We create a typed memory descriptor for map nodes.
|
||||
*/
|
||||
GC_word w[GC_BITMAP_SIZE(GSIMapNode_t)] = {0};
|
||||
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, key));
|
||||
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, value));
|
||||
nodeDesc = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
|
||||
#endif
|
||||
if (globalClassMap == 0)
|
||||
{
|
||||
globalClassMap =
|
||||
|
@ -817,9 +835,11 @@ static NSDictionary *makeReference(unsigned ref)
|
|||
* Set up map tables.
|
||||
*/
|
||||
#if GS_WITH_GC
|
||||
zone = GSIMapStrongKeyAndVal;
|
||||
#endif
|
||||
_cIdMap = (GSIMapTable)NSAllocateCollectable(sizeof(GSIMapTable_t)*5,
|
||||
NSScannedOption);
|
||||
#else
|
||||
_cIdMap = (GSIMapTable)NSZoneMalloc(zone, sizeof(GSIMapTable_t)*5);
|
||||
#endif
|
||||
_uIdMap = &_cIdMap[1];
|
||||
_repMap = &_cIdMap[2];
|
||||
GSIMapInitWithZoneAndCapacity(_cIdMap, zone, 10);
|
||||
|
|
|
@ -37,8 +37,13 @@
|
|||
/*
|
||||
* Setup for inline operation of arrays.
|
||||
*/
|
||||
#define GSI_ARRAY_RETAIN(A, X) RETAIN((X).obj)
|
||||
#define GSI_ARRAY_RELEASE(A, X) RELEASE((X).obj)
|
||||
#if GS_WITH_GC
|
||||
#define GSI_ARRAY_RETAIN(A, X)
|
||||
#define GSI_ARRAY_RELEASE(A, X)
|
||||
#else
|
||||
#define GSI_ARRAY_RETAIN(A, X) [(X).obj retain]
|
||||
#define GSI_ARRAY_RELEASE(A, X) [(X).obj release]
|
||||
#endif
|
||||
#define GSI_ARRAY_TYPES GSUNION_OBJ
|
||||
|
||||
|
||||
|
|
|
@ -67,8 +67,40 @@ typedef struct {
|
|||
(M->extra.v.retain)((NSMapTable*)M, X.ptr)
|
||||
#define GSI_MAP_ENUMERATOR NSMapEnumerator
|
||||
|
||||
#if GS_WITH_GC
|
||||
#include <gc_typed.h>
|
||||
static GC_descr nodeSS = 0;
|
||||
static GC_descr nodeSW = 0;
|
||||
static GC_descr nodeWS = 0;
|
||||
static GC_descr nodeWW = 0;
|
||||
#define GSI_MAP_NODES(M, X) \
|
||||
(GSIMapNode)GC_calloc_explicitly_typed(X, sizeof(GSIMapNode_t), (GC_descr)M->zone)
|
||||
#endif
|
||||
|
||||
#include "GNUstepBase/GSIMap.h"
|
||||
|
||||
#if GS_WITH_GC
|
||||
static void
|
||||
initialize()
|
||||
{
|
||||
/* We create a typed memory descriptor for map nodes.
|
||||
*/
|
||||
if (nodeSS == 0)
|
||||
{
|
||||
GC_word w[GC_BITMAP_SIZE(GSIMapNode_t)] = {0};
|
||||
|
||||
nodeWW = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
|
||||
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, key));
|
||||
nodeSW = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
|
||||
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, value));
|
||||
nodeSS = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
|
||||
memset(&w[0], '\0', sizeof(w));
|
||||
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, value));
|
||||
nodeWS = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/**** Function Implementations ****/
|
||||
|
||||
/**
|
||||
|
@ -208,9 +240,9 @@ NSCopyMapTableWithZone(NSMapTable *table, NSZone *zone)
|
|||
}
|
||||
|
||||
#if GS_WITH_GC
|
||||
zone = GSIMapStrongKeyAndVal;
|
||||
t = (GSIMapTable)NSAllocateCollectable(sizeof(GSIMapTable_t),
|
||||
NSScannedOption);
|
||||
zone = ((GSIMapTable)table)->zone;
|
||||
#else
|
||||
t = (GSIMapTable)NSZoneMalloc(zone, sizeof(GSIMapTable_t));
|
||||
#endif
|
||||
|
@ -277,9 +309,10 @@ NSCreateMapTableWithZone(
|
|||
GSIMapTable table;
|
||||
|
||||
#if GS_WITH_GC
|
||||
zone = GSIMapStrongKeyAndVal;
|
||||
initialize();
|
||||
table = (GSIMapTable)NSAllocateCollectable(sizeof(GSIMapTable_t),
|
||||
NSScannedOption);
|
||||
zone = (NSZone*)nodeSS;
|
||||
#else
|
||||
table = (GSIMapTable)NSZoneMalloc(zone, sizeof(GSIMapTable_t));
|
||||
#endif
|
||||
|
@ -355,10 +388,14 @@ NSFreeMapTable(NSMapTable *table)
|
|||
}
|
||||
else
|
||||
{
|
||||
#if GS_WITH_GC
|
||||
GSIMapEmptyMap((GSIMapTable)table);
|
||||
#else
|
||||
NSZone *z = ((GSIMapTable)table)->zone;
|
||||
|
||||
GSIMapEmptyMap((GSIMapTable)table);
|
||||
NSZoneFree(z, table);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -212,6 +212,13 @@ static void obsFree(Observation *o);
|
|||
#define GSI_MAP_VEXTRA Observation*
|
||||
#define GSI_MAP_EXTRA void*
|
||||
|
||||
#if GS_WITH_GC
|
||||
#include <gc_typed.h>
|
||||
static GC_descr nodeDesc; // Type descriptor for map node.
|
||||
#define GSI_MAP_NODES(M, X) \
|
||||
(GSIMapNode)GC_calloc_explicitly_typed(X, sizeof(GSIMapNode_t), nodeDesc)
|
||||
#endif
|
||||
|
||||
#include "GNUstepBase/GSIMap.h"
|
||||
|
||||
@class GSLazyRecursiveLock;
|
||||
|
@ -285,7 +292,7 @@ static Observation *obsNew(NCTable* t)
|
|||
size = CHUNKSIZE * sizeof(Observation);
|
||||
#if GS_WITH_GC
|
||||
t->chunks[t->numChunks - 1]
|
||||
= (Observation*)NSZoneMalloc(GSAtomicMallocZone(), size);
|
||||
= (Observation*)NSAllocateCollectable(size, 0);
|
||||
#else
|
||||
t->chunks[t->numChunks - 1]
|
||||
= (Observation*)NSZoneMalloc(NSDefaultMallocZone(), size);
|
||||
|
@ -313,11 +320,10 @@ static GSIMapTable mapNew(NCTable *t)
|
|||
|
||||
#if GS_WITH_GC
|
||||
m = NSAllocateCollectable(sizeof(GSIMapTable_t), NSScannedOption);
|
||||
GSIMapInitWithZoneAndCapacity(m, GSIMapStrongKeyAndVal, 2);
|
||||
#else
|
||||
m = NSZoneMalloc(_zone, sizeof(GSIMapTable_t));
|
||||
GSIMapInitWithZoneAndCapacity(m, _zone, 2);
|
||||
#endif
|
||||
GSIMapInitWithZoneAndCapacity(m, _zone, 2);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
@ -623,7 +629,12 @@ static NSNotificationCenter *default_center = nil;
|
|||
if (self == [NSNotificationCenter class])
|
||||
{
|
||||
#if GS_WITH_GC
|
||||
_zone = GSIMapStrongKeyAndVal;
|
||||
/* We create a typed memory descriptor for map nodes.
|
||||
*/
|
||||
GC_word w[GC_BITMAP_SIZE(GSIMapNode_t)] = {0};
|
||||
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, key));
|
||||
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, value));
|
||||
nodeDesc = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
|
||||
#else
|
||||
_zone = NSDefaultMallocZone();
|
||||
#endif
|
||||
|
|
|
@ -61,6 +61,13 @@
|
|||
#define GSI_MAP_EQUAL(M, X,Y) ((X).ptr == (Y).ptr)
|
||||
#define GSI_MAP_NOCLEAN 1
|
||||
|
||||
#if GS_WITH_GC
|
||||
#include <gc_typed.h>
|
||||
static GC_descr nodeDesc; // Type descriptor for map node.
|
||||
#define GSI_MAP_NODES(M, X) \
|
||||
(GSIMapNode)GC_calloc_explicitly_typed(X, sizeof(GSIMapNode_t), nodeDesc)
|
||||
#endif
|
||||
|
||||
#include "GNUstepBase/GSIMap.h"
|
||||
|
||||
/*
|
||||
|
@ -360,6 +367,14 @@ static IMP _xRefImp; /* Serialize a crossref. */
|
|||
_eTagImp = [mutableDataClass instanceMethodForSelector: eTagSel];
|
||||
_xRefImp = [mutableDataClass instanceMethodForSelector: xRefSel];
|
||||
mutableDictionaryClass = [NSMutableDictionary class];
|
||||
#if GS_WITH_GC
|
||||
/* We create a typed memory descriptor for map nodes.
|
||||
*/
|
||||
GC_word w[GC_BITMAP_SIZE(GSIMapNode_t)] = {0};
|
||||
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, key));
|
||||
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, value));
|
||||
nodeDesc = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1739,14 +1754,17 @@ static IMP _xRefImp; /* Serialize a crossref. */
|
|||
_eObjImp = [self methodForSelector: eObjSel];
|
||||
_eValImp = [self methodForSelector: eValSel];
|
||||
|
||||
#if GS_WITH_GC
|
||||
_zone = GSIMapStrongKeyAndVal;
|
||||
#endif
|
||||
/*
|
||||
* Set up map tables.
|
||||
*/
|
||||
#if GS_WITH_GC
|
||||
_clsMap
|
||||
= (GSIMapTable)NSAllocateCollectable(sizeof(GSIMapTable_t)*4,
|
||||
NSScannedOption);
|
||||
#else
|
||||
_clsMap
|
||||
= (GSIMapTable)NSZoneMalloc(_zone, sizeof(GSIMapTable_t)*4);
|
||||
#endif
|
||||
_cIdMap = &_clsMap[1];
|
||||
_uIdMap = &_clsMap[2];
|
||||
_ptrMap = &_clsMap[3];
|
||||
|
|
|
@ -746,7 +746,7 @@ static inline BOOL timerInvalidated(NSTimer *t)
|
|||
NSObjectMapValueCallBacks, 0);
|
||||
_timedPerformers = [[NSMutableArray alloc] initWithCapacity: 8];
|
||||
#ifdef HAVE_POLL_F
|
||||
_extra = objc_malloc(sizeof(pollextra));
|
||||
_extra = NSZoneMalloc(NSDefaultMallocZone(), sizeof(pollextra));
|
||||
memset(_extra, '\0', sizeof(pollextra));
|
||||
#endif
|
||||
}
|
||||
|
@ -767,8 +767,8 @@ static inline BOOL timerInvalidated(NSTimer *t)
|
|||
pollextra *e = (pollextra*)_extra;
|
||||
|
||||
if (e->index != 0)
|
||||
objc_free(e->index);
|
||||
objc_free(e);
|
||||
NSZoneFree(NSDefaultMallocZone(), e->index);
|
||||
NSZoneFree(NSDefaultMallocZone(), e);
|
||||
}
|
||||
#endif
|
||||
RELEASE(_contextStack);
|
||||
|
|
|
@ -63,6 +63,11 @@
|
|||
#define GSI_MAP_EQUAL(M, X,Y) [(X).obj isEqualToString: (Y).obj]
|
||||
#define GSI_MAP_NOCLEAN 1
|
||||
|
||||
#if GS_WITH_GC
|
||||
#define GSI_MAP_NODES(M, X) \
|
||||
(GSIMapNode)NSAllocateCollectable(X * sizeof(GSIMapNode_t), 0)
|
||||
#endif
|
||||
|
||||
#include "GNUstepBase/GSIMap.h"
|
||||
|
||||
/*
|
||||
|
@ -157,11 +162,7 @@ initSerializerInfo(_NSSerializerInfo* info, NSMutableData *d, BOOL u)
|
|||
(*info->appImp)(d, appSel, &info->shouldUnique, 1);
|
||||
if (u)
|
||||
{
|
||||
#if GS_WITH_GC
|
||||
GSIMapInitWithZoneAndCapacity(&info->map, GSIMapStrongKeyAndVal, 16);
|
||||
#else
|
||||
GSIMapInitWithZoneAndCapacity(&info->map, NSDefaultMallocZone(), 16);
|
||||
#endif
|
||||
info->count = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,7 +142,11 @@ static char *buildURL(parsedURL *base, parsedURL *rel, BOOL standardize)
|
|||
len += strlen(rel->fragment) + 1; // #fragment
|
||||
}
|
||||
|
||||
ptr = buf = (char*)NSZoneMalloc(GSAtomicMallocZone(), len);
|
||||
#if GS_WITH_GC
|
||||
ptr = buf = (char*)NSAllocateCollectable(len, 0);
|
||||
#else
|
||||
ptr = buf = (char*)NSZoneMalloc(NSDefaultMallocZone(), len);
|
||||
#endif
|
||||
|
||||
if (rel->scheme != 0)
|
||||
{
|
||||
|
@ -698,7 +702,11 @@ static unsigned urlAlign;
|
|||
BOOL canBeGeneric = YES;
|
||||
|
||||
size += sizeof(parsedURL) + urlAlign + 1;
|
||||
buf = _data = (parsedURL*)NSZoneMalloc(GSAtomicMallocZone(), size);
|
||||
#if GS_WITH_GC
|
||||
buf = _data = (parsedURL*)NSAllocateCollectable(size, 0);
|
||||
#else
|
||||
buf = _data = (parsedURL*)NSZoneMalloc(NSDefaultMallocZone(), size);
|
||||
#endif
|
||||
memset(buf, '\0', size);
|
||||
start = end = ptr = (char*)&buf[1];
|
||||
[_urlString getCString: start
|
||||
|
|
|
@ -1780,10 +1780,12 @@ NSAllocateCollectable(NSUInteger size, NSUInteger options)
|
|||
if (options & NSCollectorDisabledOption)
|
||||
{
|
||||
ptr = (void*)GC_MALLOC_UNCOLLECTABLE(size);
|
||||
memset(ptr, '\0', size);
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr = (void*)GC_MALLOC(size);
|
||||
memset(ptr, '\0', size);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1795,6 +1797,7 @@ NSAllocateCollectable(NSUInteger size, NSUInteger options)
|
|||
else
|
||||
{
|
||||
ptr = (void*)GC_MALLOC_ATOMIC(size);
|
||||
memset(ptr, '\0', size);
|
||||
}
|
||||
}
|
||||
return ptr;
|
||||
|
@ -1940,6 +1943,7 @@ NSZoneCalloc (NSZone *zone, NSUInteger elems, NSUInteger bytes)
|
|||
if (zone == &atomic_zone)
|
||||
{
|
||||
ptr = (void*)GC_MALLOC_ATOMIC(size);
|
||||
memset(ptr, '\0', size);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -98,7 +98,7 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
|
|||
#ifdef HAVE_POLL_F
|
||||
if (pollfds != 0)
|
||||
{
|
||||
objc_free(pollfds);
|
||||
NSZoneFree(NSDefaultMallocZone(), pollfds);
|
||||
}
|
||||
#endif
|
||||
[super dealloc];
|
||||
|
@ -175,16 +175,18 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
|
|||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
NSZone *z = [self zone];
|
||||
NSZone *z;
|
||||
|
||||
mode = [theMode copy];
|
||||
extra = e;
|
||||
#if GS_WITH_GC
|
||||
z = (NSZone*)1;
|
||||
performers = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption);
|
||||
timers = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption);
|
||||
watchers = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption);
|
||||
_trigger = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption);
|
||||
#else
|
||||
z = [self zone];
|
||||
performers = NSZoneMalloc(z, sizeof(GSIArray_t));
|
||||
timers = NSZoneMalloc(z, sizeof(GSIArray_t));
|
||||
watchers = NSZoneMalloc(z, sizeof(GSIArray_t));
|
||||
|
@ -224,7 +226,8 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt)
|
|||
pe->index
|
||||
= NSAllocateCollectable(pe->limit * sizeof(*(pe->index)), 0);
|
||||
#else
|
||||
pe->index = objc_malloc(pe->limit * sizeof(*(pe->index)));
|
||||
pe->index = NSZoneMalloc(NSDefaultMallocZone(),
|
||||
pe->limit * sizeof(*(pe->index)));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
|
@ -233,7 +236,8 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt)
|
|||
pe->index = NSReallocateCollectable(pe->index,
|
||||
pe->limit * sizeof(*(pe->index)), 0);
|
||||
#else
|
||||
pe->index = objc_realloc(pe->index, pe->limit * sizeof(*(pe->index)));
|
||||
pe->index = NSZoneRealloc(NSDefaultMallocZone(),
|
||||
pe->index, pe->limit * sizeof(*(pe->index)));
|
||||
#endif
|
||||
}
|
||||
do
|
||||
|
@ -252,8 +256,8 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt)
|
|||
pollfds = NSReallocateCollectable(pollfds,
|
||||
ctxt->pollfds_capacity * sizeof (*pollfds), 0);
|
||||
#else
|
||||
pollfds =
|
||||
objc_realloc(pollfds, ctxt->pollfds_capacity * sizeof (*pollfds));
|
||||
pollfds = NSZoneRealloc(NSDefaultMallocZone(),
|
||||
pollfds, ctxt->pollfds_capacity * sizeof (*pollfds));
|
||||
#endif
|
||||
ctxt->pollfds = pollfds;
|
||||
}
|
||||
|
@ -307,7 +311,8 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt)
|
|||
pollfds
|
||||
= NSAllocateCollectable(pollfds_capacity * sizeof(*pollfds), 0);
|
||||
#else
|
||||
pollfds = objc_malloc(pollfds_capacity * sizeof(*pollfds));
|
||||
pollfds = NSZoneMalloc(NSDefaultMallocZone(),
|
||||
pollfds_capacity * sizeof(*pollfds));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
|
@ -316,7 +321,8 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt)
|
|||
pollfds = NSReallocateCollectable(pollfds,
|
||||
pollfds_capacity * sizeof(*pollfds), 0);
|
||||
#else
|
||||
pollfds = objc_realloc(pollfds, pollfds_capacity * sizeof(*pollfds));
|
||||
pollfds = NSZoneRealloc(NSDefaultMallocZone(),
|
||||
pollfds, pollfds_capacity * sizeof(*pollfds));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,16 +147,18 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
|
|||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
NSZone *z = [self zone];
|
||||
NSZone *z;
|
||||
|
||||
mode = [theMode copy];
|
||||
extra = e;
|
||||
#if GS_WITH_GC
|
||||
z = (NSZone*)1;
|
||||
performers = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption);
|
||||
timers = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption);
|
||||
watchers = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption);
|
||||
_trigger = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption);
|
||||
#else
|
||||
z = [self zone];
|
||||
performers = NSZoneMalloc(z, sizeof(GSIArray_t));
|
||||
timers = NSZoneMalloc(z, sizeof(GSIArray_t));
|
||||
watchers = NSZoneMalloc(z, sizeof(GSIArray_t));
|
||||
|
|
Loading…
Reference in a new issue