diff --git a/ChangeLog b/ChangeLog index 70d548867..0984bc599 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2009-02-11 Richard Frith-Macdonald + + * Source/NSUnarchiver.m: + * Source/NSString.m: + * Source/Additions/GSMime.m: + * Source/NSData.m: + * Source/GSHTTPAuthentication.m: + * Source/NSSerializer.m: + Various changes to use unscanned collectable memory with GC. + 2009-02-11 Richard Frith-Macdonald * Source/NSNotificationCenter.m: Fix bug removing observations for diff --git a/Source/Additions/GSMime.m b/Source/Additions/GSMime.m index 7a6231038..c0bb8d586 100644 --- a/Source/Additions/GSMime.m +++ b/Source/Additions/GSMime.m @@ -1697,8 +1697,13 @@ wordData(NSString *word) if (tmp != nil) { unsigned int l = [tmp cStringLength] + 2; - unsigned char *b = NSZoneMalloc(NSDefaultMallocZone(), l + 1); + unsigned char *b; +#if GS_WITH_GC + b = NSAllocateCollectable(l + 1, 0); +#else + b = NSZoneMalloc(NSDefaultMallocZone(), l + 1); +#endif b[0] = '-'; b[1] = '-'; [tmp getCString: (char*)&b[2]]; @@ -3733,7 +3738,11 @@ appendString(NSMutableData *m, unsigned offset, unsigned fold, src = (const unsigned char*)[source bytes]; end = &src[length]; +#if GS_WITH_GC + result = (unsigned char*)NSAllocateCollectable(declen, 0); +#else result = (unsigned char*)NSZoneMalloc(NSDefaultMallocZone(), declen); +#endif dst = result; while ((src != end) && *src != '\0') @@ -3859,7 +3868,11 @@ appendString(NSMutableData *m, unsigned offset, unsigned fold, } destlen = 4 * ((length + 2) / 3); sBuf = (unsigned char*)[source bytes]; +#if GS_WITH_GC + dBuf = NSAllocateCollectable(destlen, 0); +#else dBuf = NSZoneMalloc(NSDefaultMallocZone(), destlen); +#endif destlen = encodebase64(dBuf, sBuf, length); diff --git a/Source/GSHTTPAuthentication.m b/Source/GSHTTPAuthentication.m index 27ac262b0..c58756d46 100644 --- a/Source/GSHTTPAuthentication.m +++ b/Source/GSHTTPAuthentication.m @@ -49,12 +49,17 @@ static GSMimeParser *mimeParser = nil; unsigned slen = [self length]; unsigned dlen = slen * 2; const unsigned char *src = (const unsigned char *)[self bytes]; - char *dst = (char*)NSZoneMalloc(NSDefaultMallocZone(), dlen); + char *dst; unsigned spos = 0; unsigned dpos = 0; NSData *data; NSString *string; +#if GS_WITH_GC + dst = (char*)NSAllocateCollectable(dlen, 0); +#else + dst = (char*)NSZoneMalloc(NSDefaultMallocZone(), dlen); +#endif while (spos < slen) { unsigned char c = src[spos++]; diff --git a/Source/NSData.m b/Source/NSData.m index f7e76abb2..85fce5454 100644 --- a/Source/NSData.m +++ b/Source/NSData.m @@ -515,7 +515,11 @@ failure: if (bufferSize > 0) { +#if GS_WITH_GC + ptr = NSAllocateCollectable(bufferSize, 0); +#else ptr = NSZoneMalloc(NSDefaultMallocZone(), bufferSize); +#endif if (ptr == 0) { DESTROY(self); diff --git a/Source/NSSerializer.m b/Source/NSSerializer.m index 0d5dd1476..0aadc8da4 100644 --- a/Source/NSSerializer.m +++ b/Source/NSSerializer.m @@ -559,7 +559,11 @@ deserializeFromInfo(_NSDeserializerInfo* info) char *b; size = (*info->deiImp)(info->data, deiSel, info->cursor); +#if GS_WITH_GC + b = NSAllocateCollectable(size, 0); +#else b = NSZoneMalloc(NSDefaultMallocZone(), size); +#endif (*info->debImp)(info->data, debSel, b, size, info->cursor); s = [[StringClass alloc] initWithBytesNoCopy: b length: size - 1 @@ -590,7 +594,11 @@ deserializeFromInfo(_NSDeserializerInfo* info) unichar *b; size = (*info->deiImp)(info->data, deiSel, info->cursor); +#if GS_WITH_GC + b = NSAllocateCollectable(size*sizeof(unichar), 0); +#else b = NSZoneMalloc(NSDefaultMallocZone(), size*sizeof(unichar)); +#endif (*info->debImp)(info->data, debSel, b, size*sizeof(unichar), info->cursor); s = [[StringClass alloc] initWithBytesNoCopy: b diff --git a/Source/NSString.m b/Source/NSString.m index 7c01e22d9..acaf859e5 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -894,8 +894,13 @@ handle_printf_atsign (FILE *stream, } else { - void *buf = NSZoneMalloc(GSObjCZone(self), length); + void *buf; +#if GS_WITH_GC + buf = NSAllocateCollectable(length, 0); +#else + buf = NSZoneMalloc(GSObjCZone(self), length); +#endif memcpy(buf, bytes, length); return [self initWithBytesNoCopy: buf length: length @@ -4615,7 +4620,11 @@ static NSFileManager *fm = nil; { unsigned char *chars; +#if GS_WITH_GC + chars = NSAllocateCollectable(count+1, 0); +#else chars = NSZoneMalloc(zone, count+1); +#endif [aCoder decodeArrayOfObjCType: @encode(unsigned char) count: count at: chars]; diff --git a/Source/NSUnarchiver.m b/Source/NSUnarchiver.m index 212d52398..6064041d0 100644 --- a/Source/NSUnarchiver.m +++ b/Source/NSUnarchiver.m @@ -1116,14 +1116,12 @@ static Class NSDataMallocClass; { void *b; NSData *d; - NSZone *z; #if GS_WITH_GC - z = GSAtomicMallocZone(); + b = NSAllocateCollectable(l, 0); #else - z = zone; + b = NSZoneMalloc(zone, l); #endif - b = NSZoneMalloc(z, l); [self decodeArrayOfObjCType: @encode(unsigned char) count: l at: b];