mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 16:50:58 +00:00
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:
parent
d7c2ea71f7
commit
7201a1f33f
7 changed files with 54 additions and 7 deletions
10
ChangeLog
10
ChangeLog
|
@ -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>
|
2009-02-11 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSNotificationCenter.m: Fix bug removing observations for
|
* Source/NSNotificationCenter.m: Fix bug removing observations for
|
||||||
|
|
|
@ -1697,8 +1697,13 @@ wordData(NSString *word)
|
||||||
if (tmp != nil)
|
if (tmp != nil)
|
||||||
{
|
{
|
||||||
unsigned int l = [tmp cStringLength] + 2;
|
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[0] = '-';
|
||||||
b[1] = '-';
|
b[1] = '-';
|
||||||
[tmp getCString: (char*)&b[2]];
|
[tmp getCString: (char*)&b[2]];
|
||||||
|
@ -3733,7 +3738,11 @@ appendString(NSMutableData *m, unsigned offset, unsigned fold,
|
||||||
src = (const unsigned char*)[source bytes];
|
src = (const unsigned char*)[source bytes];
|
||||||
end = &src[length];
|
end = &src[length];
|
||||||
|
|
||||||
|
#if GS_WITH_GC
|
||||||
|
result = (unsigned char*)NSAllocateCollectable(declen, 0);
|
||||||
|
#else
|
||||||
result = (unsigned char*)NSZoneMalloc(NSDefaultMallocZone(), declen);
|
result = (unsigned char*)NSZoneMalloc(NSDefaultMallocZone(), declen);
|
||||||
|
#endif
|
||||||
dst = result;
|
dst = result;
|
||||||
|
|
||||||
while ((src != end) && *src != '\0')
|
while ((src != end) && *src != '\0')
|
||||||
|
@ -3859,7 +3868,11 @@ appendString(NSMutableData *m, unsigned offset, unsigned fold,
|
||||||
}
|
}
|
||||||
destlen = 4 * ((length + 2) / 3);
|
destlen = 4 * ((length + 2) / 3);
|
||||||
sBuf = (unsigned char*)[source bytes];
|
sBuf = (unsigned char*)[source bytes];
|
||||||
|
#if GS_WITH_GC
|
||||||
|
dBuf = NSAllocateCollectable(destlen, 0);
|
||||||
|
#else
|
||||||
dBuf = NSZoneMalloc(NSDefaultMallocZone(), destlen);
|
dBuf = NSZoneMalloc(NSDefaultMallocZone(), destlen);
|
||||||
|
#endif
|
||||||
|
|
||||||
destlen = encodebase64(dBuf, sBuf, length);
|
destlen = encodebase64(dBuf, sBuf, length);
|
||||||
|
|
||||||
|
|
|
@ -49,12 +49,17 @@ static GSMimeParser *mimeParser = nil;
|
||||||
unsigned slen = [self length];
|
unsigned slen = [self length];
|
||||||
unsigned dlen = slen * 2;
|
unsigned dlen = slen * 2;
|
||||||
const unsigned char *src = (const unsigned char *)[self bytes];
|
const unsigned char *src = (const unsigned char *)[self bytes];
|
||||||
char *dst = (char*)NSZoneMalloc(NSDefaultMallocZone(), dlen);
|
char *dst;
|
||||||
unsigned spos = 0;
|
unsigned spos = 0;
|
||||||
unsigned dpos = 0;
|
unsigned dpos = 0;
|
||||||
NSData *data;
|
NSData *data;
|
||||||
NSString *string;
|
NSString *string;
|
||||||
|
|
||||||
|
#if GS_WITH_GC
|
||||||
|
dst = (char*)NSAllocateCollectable(dlen, 0);
|
||||||
|
#else
|
||||||
|
dst = (char*)NSZoneMalloc(NSDefaultMallocZone(), dlen);
|
||||||
|
#endif
|
||||||
while (spos < slen)
|
while (spos < slen)
|
||||||
{
|
{
|
||||||
unsigned char c = src[spos++];
|
unsigned char c = src[spos++];
|
||||||
|
|
|
@ -515,7 +515,11 @@ failure:
|
||||||
|
|
||||||
if (bufferSize > 0)
|
if (bufferSize > 0)
|
||||||
{
|
{
|
||||||
|
#if GS_WITH_GC
|
||||||
|
ptr = NSAllocateCollectable(bufferSize, 0);
|
||||||
|
#else
|
||||||
ptr = NSZoneMalloc(NSDefaultMallocZone(), bufferSize);
|
ptr = NSZoneMalloc(NSDefaultMallocZone(), bufferSize);
|
||||||
|
#endif
|
||||||
if (ptr == 0)
|
if (ptr == 0)
|
||||||
{
|
{
|
||||||
DESTROY(self);
|
DESTROY(self);
|
||||||
|
|
|
@ -559,7 +559,11 @@ deserializeFromInfo(_NSDeserializerInfo* info)
|
||||||
char *b;
|
char *b;
|
||||||
|
|
||||||
size = (*info->deiImp)(info->data, deiSel, info->cursor);
|
size = (*info->deiImp)(info->data, deiSel, info->cursor);
|
||||||
|
#if GS_WITH_GC
|
||||||
|
b = NSAllocateCollectable(size, 0);
|
||||||
|
#else
|
||||||
b = NSZoneMalloc(NSDefaultMallocZone(), size);
|
b = NSZoneMalloc(NSDefaultMallocZone(), size);
|
||||||
|
#endif
|
||||||
(*info->debImp)(info->data, debSel, b, size, info->cursor);
|
(*info->debImp)(info->data, debSel, b, size, info->cursor);
|
||||||
s = [[StringClass alloc] initWithBytesNoCopy: b
|
s = [[StringClass alloc] initWithBytesNoCopy: b
|
||||||
length: size - 1
|
length: size - 1
|
||||||
|
@ -590,7 +594,11 @@ deserializeFromInfo(_NSDeserializerInfo* info)
|
||||||
unichar *b;
|
unichar *b;
|
||||||
|
|
||||||
size = (*info->deiImp)(info->data, deiSel, info->cursor);
|
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));
|
b = NSZoneMalloc(NSDefaultMallocZone(), size*sizeof(unichar));
|
||||||
|
#endif
|
||||||
(*info->debImp)(info->data, debSel, b, size*sizeof(unichar),
|
(*info->debImp)(info->data, debSel, b, size*sizeof(unichar),
|
||||||
info->cursor);
|
info->cursor);
|
||||||
s = [[StringClass alloc] initWithBytesNoCopy: b
|
s = [[StringClass alloc] initWithBytesNoCopy: b
|
||||||
|
|
|
@ -894,8 +894,13 @@ handle_printf_atsign (FILE *stream,
|
||||||
}
|
}
|
||||||
else
|
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);
|
memcpy(buf, bytes, length);
|
||||||
return [self initWithBytesNoCopy: buf
|
return [self initWithBytesNoCopy: buf
|
||||||
length: length
|
length: length
|
||||||
|
@ -4615,7 +4620,11 @@ static NSFileManager *fm = nil;
|
||||||
{
|
{
|
||||||
unsigned char *chars;
|
unsigned char *chars;
|
||||||
|
|
||||||
|
#if GS_WITH_GC
|
||||||
|
chars = NSAllocateCollectable(count+1, 0);
|
||||||
|
#else
|
||||||
chars = NSZoneMalloc(zone, count+1);
|
chars = NSZoneMalloc(zone, count+1);
|
||||||
|
#endif
|
||||||
[aCoder decodeArrayOfObjCType: @encode(unsigned char)
|
[aCoder decodeArrayOfObjCType: @encode(unsigned char)
|
||||||
count: count
|
count: count
|
||||||
at: chars];
|
at: chars];
|
||||||
|
|
|
@ -1116,14 +1116,12 @@ static Class NSDataMallocClass;
|
||||||
{
|
{
|
||||||
void *b;
|
void *b;
|
||||||
NSData *d;
|
NSData *d;
|
||||||
NSZone *z;
|
|
||||||
|
|
||||||
#if GS_WITH_GC
|
#if GS_WITH_GC
|
||||||
z = GSAtomicMallocZone();
|
b = NSAllocateCollectable(l, 0);
|
||||||
#else
|
#else
|
||||||
z = zone;
|
b = NSZoneMalloc(zone, l);
|
||||||
#endif
|
#endif
|
||||||
b = NSZoneMalloc(z, l);
|
|
||||||
[self decodeArrayOfObjCType: @encode(unsigned char)
|
[self decodeArrayOfObjCType: @encode(unsigned char)
|
||||||
count: l
|
count: l
|
||||||
at: b];
|
at: b];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue