GC improvements

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27848 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2009-02-11 17:33:31 +00:00
parent d2fa82f877
commit 43a0af2382
7 changed files with 54 additions and 7 deletions

View file

@ -1,3 +1,13 @@
2009-02-11 Richard Frith-Macdonald <rfm@gnu.org>
* 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 <rfm@gnu.org>
* Source/NSNotificationCenter.m: Fix bug removing observations for

View file

@ -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);

View file

@ -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++];

View file

@ -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);

View file

@ -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

View file

@ -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];

View file

@ -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];