Tidy memory allocation for empty strings.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@4507 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 1999-07-02 13:26:37 +00:00
parent a712b04807
commit 601742f5f9
4 changed files with 323 additions and 186 deletions

View file

@ -1,9 +1,12 @@
Fre Jul 2 12:10:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk> Fri Jul 2 14:20:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/GSeq.h: Fix boundary error when searching for string in * Source/GSeq.h: Fix boundary error when searching for string in
string. string.
* Source/NSString.m: Don't allocate contents for string with 0 length.
* Source/NSGString.m: ditto
* Source/NSGCString.m: ditto
Fre Jul 2 8:45:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk> Fri Jul 2 8:45:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/NSUnarchiver.m: In designated initialiser, catch exceptions * Source/NSUnarchiver.m: In designated initialiser, catch exceptions
and deallocate self before re-throwing in order to prevent memory and deallocate self before re-throwing in order to prevent memory

View file

@ -92,14 +92,14 @@ static IMP msInitImp; /* designated initialiser for mutable */
} }
} }
+ allocWithZone: (NSZone*)z + (id) allocWithZone: (NSZone*)z
{ {
return NSAllocateObject (self, 0, z); return NSAllocateObject(self, 0, z);
} }
+ alloc + (id) alloc
{ {
return NSAllocateObject (self, 0, NSDefaultMallocZone()); return NSAllocateObject(self, 0, NSDefaultMallocZone());
} }
- (void)dealloc - (void)dealloc
@ -144,7 +144,7 @@ static IMP msInitImp; /* designated initialiser for mutable */
{ {
NSZone *z; NSZone *z;
if (flag) if (flag && byteString)
{ {
z = NSZoneFromPointer(byteString); z = NSZoneFromPointer(byteString);
} }
@ -198,7 +198,7 @@ static IMP msInitImp; /* designated initialiser for mutable */
} }
} }
- (void) encodeWithCoder: aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
[aCoder encodeValueOfObjCType:@encode(unsigned) at:&_count]; [aCoder encodeValueOfObjCType:@encode(unsigned) at:&_count];
if (_count > 0) if (_count > 0)
@ -209,7 +209,7 @@ static IMP msInitImp; /* designated initialiser for mutable */
} }
} }
- initWithCoder: aCoder - (id) initWithCoder: (NSCoder*)aCoder
{ {
[aCoder decodeValueOfObjCType:@encode(unsigned) [aCoder decodeValueOfObjCType:@encode(unsigned)
at:&_count]; at:&_count];
@ -224,7 +224,7 @@ static IMP msInitImp; /* designated initialiser for mutable */
return self; return self;
} }
- copy - (id) copy
{ {
NSZone *z = NSDefaultMallocZone(); NSZone *z = NSDefaultMallocZone();
@ -234,8 +234,16 @@ static IMP msInitImp; /* designated initialiser for mutable */
char *tmp; char *tmp;
obj = (NSGCString*)NSAllocateObject(_fastCls._NSGCString, 0, z); obj = (NSGCString*)NSAllocateObject(_fastCls._NSGCString, 0, z);
if (_count)
{
tmp = NSZoneMalloc(z, _count); tmp = NSZoneMalloc(z, _count);
memcpy(tmp, _contents_chars, _count); memcpy(tmp, _contents_chars, _count);
}
else
{
tmp = 0;
z = 0;
}
obj = (*csInitImp)(obj, csInitSel, tmp, _count, z); obj = (*csInitImp)(obj, csInitSel, tmp, _count, z);
if (_hash && obj) if (_hash && obj)
{ {
@ -249,7 +257,7 @@ static IMP msInitImp; /* designated initialiser for mutable */
} }
} }
- copyWithZone: (NSZone*)z - (id) copyWithZone: (NSZone*)z
{ {
if (NSShouldRetainWithZone(self, z) == NO) if (NSShouldRetainWithZone(self, z) == NO)
{ {
@ -257,8 +265,16 @@ static IMP msInitImp; /* designated initialiser for mutable */
char *tmp; char *tmp;
obj = (NSGCString*)NSAllocateObject(_fastCls._NSGCString, 0, z); obj = (NSGCString*)NSAllocateObject(_fastCls._NSGCString, 0, z);
if (_count)
{
tmp = NSZoneMalloc(z, _count); tmp = NSZoneMalloc(z, _count);
memcpy(tmp, _contents_chars, _count); memcpy(tmp, _contents_chars, _count);
}
else
{
tmp = 0;
z = 0;
}
obj = (*csInitImp)(obj, csInitSel, tmp, _count, z); obj = (*csInitImp)(obj, csInitSel, tmp, _count, z);
if (_hash && obj) if (_hash && obj)
{ {
@ -272,7 +288,7 @@ static IMP msInitImp; /* designated initialiser for mutable */
} }
} }
- mutableCopy - (id) mutableCopy
{ {
NSGMutableCString *obj; NSGMutableCString *obj;
@ -293,7 +309,7 @@ static IMP msInitImp; /* designated initialiser for mutable */
return obj; return obj;
} }
- mutableCopyWithZone: (NSZone*)z - (id) mutableCopyWithZone: (NSZone*)z
{ {
NSGMutableCString *obj; NSGMutableCString *obj;
@ -525,11 +541,21 @@ static IMP msInitImp; /* designated initialiser for mutable */
- (id) initWithString: (NSString*)string - (id) initWithString: (NSString*)string
{ {
NSZone *z = fastZone(self);
unsigned length = [string cStringLength]; unsigned length = [string cStringLength];
char *buf = NSZoneMalloc(z, length+1); // getCString appends a nul. NSZone *z;
char *buf;
if (length > 0)
{
z = fastZone(self);
buf = NSZoneMalloc(z, length+1); // getCString appends a nul.
[string getCString: buf]; [string getCString: buf];
}
else
{
z = 0;
buf = 0;
}
return [self initWithCStringNoCopy: buf length: length fromZone: z]; return [self initWithCStringNoCopy: buf length: length fromZone: z];
} }
@ -747,14 +773,14 @@ static IMP msInitImp; /* designated initialiser for mutable */
@implementation NSGMutableCString @implementation NSGMutableCString
+ allocWithZone: (NSZone*)z + (id) allocWithZone: (NSZone*)z
{ {
return NSAllocateObject (self, 0, z); return NSAllocateObject(self, 0, z);
} }
+ alloc + (id) alloc
{ {
return NSAllocateObject (self, 0, NSDefaultMallocZone()); return NSAllocateObject(self, 0, NSDefaultMallocZone());
} }
+ (void) initialize + (void) initialize
@ -822,7 +848,7 @@ stringDecrementCountAndFillHoleAt(NSGMutableCStringStruct *self,
} }
/* This is the designated initializer for this class */ /* This is the designated initializer for this class */
- initWithCapacity: (unsigned)capacity - (id) initWithCapacity: (unsigned)capacity
{ {
_count = 0; _count = 0;
_capacity = capacity; _capacity = capacity;
@ -873,15 +899,23 @@ stringDecrementCountAndFillHoleAt(NSGMutableCStringStruct *self,
return a; return a;
} }
- copy - (id) copy
{ {
char *tmp; char *tmp;
NSGCString *obj; NSGCString *obj;
NSZone *z = NSDefaultMallocZone(); NSZone *z = NSDefaultMallocZone();
obj = (NSGCString*)NSAllocateObject(_fastCls._NSGCString, 0, z); obj = (NSGCString*)NSAllocateObject(_fastCls._NSGCString, 0, z);
if (_count)
{
tmp = NSZoneMalloc(z, _count); tmp = NSZoneMalloc(z, _count);
memcpy(tmp, _contents_chars, _count); memcpy(tmp, _contents_chars, _count);
}
else
{
tmp = 0;
z = 0;
}
obj = (*csInitImp)(obj, csInitSel, tmp, _count, z); obj = (*csInitImp)(obj, csInitSel, tmp, _count, z);
if (_hash && obj) if (_hash && obj)
{ {
@ -892,14 +926,22 @@ stringDecrementCountAndFillHoleAt(NSGMutableCStringStruct *self,
return obj; return obj;
} }
- copyWithZone: (NSZone*)z - (id) copyWithZone: (NSZone*)z
{ {
char *tmp; char *tmp;
NSGCString *obj; NSGCString *obj;
obj = (NSGCString*)NSAllocateObject(_fastCls._NSGCString, 0, z); obj = (NSGCString*)NSAllocateObject(_fastCls._NSGCString, 0, z);
if (_count)
{
tmp = NSZoneMalloc(z, _count); tmp = NSZoneMalloc(z, _count);
memcpy(tmp, _contents_chars, _count); memcpy(tmp, _contents_chars, _count);
}
else
{
tmp = 0;
z = 0;
}
obj = (*csInitImp)(obj, csInitSel, tmp, _count, z); obj = (*csInitImp)(obj, csInitSel, tmp, _count, z);
if (_hash && obj) if (_hash && obj)
{ {
@ -910,7 +952,7 @@ stringDecrementCountAndFillHoleAt(NSGMutableCStringStruct *self,
return obj; return obj;
} }
- mutableCopy - (id) mutableCopy
{ {
NSGMutableCString *obj; NSGMutableCString *obj;
@ -1030,7 +1072,7 @@ stringDecrementCountAndFillHoleAt(NSGMutableCStringStruct *self,
range.location, range.length); range.location, range.length);
} }
- initWithCoder: aCoder - (id) initWithCoder: (NSCoder*)aCoder
{ {
unsigned cap; unsigned cap;

View file

@ -163,7 +163,8 @@
fromZone: (NSZone*)zone fromZone: (NSZone*)zone
{ {
self = [super init]; self = [super init];
if (self) { if (self)
{
_count = length; _count = length;
_contents_chars = chars; _contents_chars = chars;
_zone = chars ? zone : 0; _zone = chars ? zone : 0;
@ -177,13 +178,16 @@
freeWhenDone: (BOOL)flag freeWhenDone: (BOOL)flag
{ {
self = [super init]; self = [super init];
if (self) { if (self)
{
_count = length; _count = length;
_contents_chars = chars; _contents_chars = chars;
if (flag) { if (flag && chars)
{
_zone = NSZoneFromPointer(chars); _zone = NSZoneFromPointer(chars);
} }
else { else
{
_zone = 0; _zone = 0;
} }
} }
@ -194,10 +198,18 @@
length: (unsigned int)length length: (unsigned int)length
{ {
NSZone *z = fastZone(self); NSZone *z = fastZone(self);
unichar *s = NSZoneMalloc(z, length*sizeof(unichar)); unichar *s;
if (length)
{
s = NSZoneMalloc(z, length*sizeof(unichar));
if (chars) if (chars)
memcpy(s, chars, sizeof(unichar)*length); memcpy(s, chars, sizeof(unichar)*length);
}
else
{
s = 0;
}
return [self initWithCharactersNoCopy:s length:length fromZone:z]; return [self initWithCharactersNoCopy:s length:length fromZone:z];
} }
@ -304,7 +316,7 @@
/* NSCoding Protocol */ /* NSCoding Protocol */
- (void) encodeWithCoder: aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
[aCoder encodeValueOfObjCType: @encode(unsigned) at: &_count]; [aCoder encodeValueOfObjCType: @encode(unsigned) at: &_count];
if (_count > 0) if (_count > 0)
@ -315,7 +327,7 @@
} }
} }
- initWithCoder: aCoder - (id) initWithCoder: (NSCoder*)aCoder
{ {
[aCoder decodeValueOfObjCType: @encode(unsigned) at: &_count]; [aCoder decodeValueOfObjCType: @encode(unsigned) at: &_count];
if (_count) if (_count)
@ -467,14 +479,14 @@
// @protocol NSMutableString <NSString> // @protocol NSMutableString <NSString>
+ allocWithZone: (NSZone*)z + (id) allocWithZone: (NSZone*)z
{ {
return NSAllocateObject (self, 0, z); return NSAllocateObject(self, 0, z);
} }
+ alloc + (id) alloc
{ {
return NSAllocateObject (self, 0, NSDefaultMallocZone()); return NSAllocateObject(self, 0, NSDefaultMallocZone());
} }
+ (void) initialize + (void) initialize
@ -541,7 +553,8 @@ stringDecrementCountAndFillHoleAt(NSGMutableStringStruct *self,
fromZone: (NSZone*)zone fromZone: (NSZone*)zone
{ {
self = [super init]; self = [super init];
if (self) { if (self)
{
_count = length; _count = length;
_capacity = length; _capacity = length;
_contents_chars = chars; _contents_chars = chars;
@ -555,26 +568,32 @@ stringDecrementCountAndFillHoleAt(NSGMutableStringStruct *self,
freeWhenDone: (BOOL)flag freeWhenDone: (BOOL)flag
{ {
self = [super init]; self = [super init];
if (self) { if (self)
{
_count = length; _count = length;
_capacity = length; _capacity = length;
_contents_chars = chars; _contents_chars = chars;
if (flag) { if (flag && chars)
{
_zone = NSZoneFromPointer(chars); _zone = NSZoneFromPointer(chars);
} }
else { else
{
_zone = 0; _zone = 0;
} }
} }
return self; return self;
} }
- initWithCapacity: (unsigned)capacity - (id) initWithCapacity: (unsigned)capacity
{ {
self = [super init]; self = [super init];
if (self) { if (self)
{
if (capacity < 2) if (capacity < 2)
{
capacity = 2; capacity = 2;
}
_count = 0; _count = 0;
_capacity = capacity; _capacity = capacity;
_zone = fastZone(self); _zone = fastZone(self);
@ -683,7 +702,7 @@ stringDecrementCountAndFillHoleAt(NSGMutableStringStruct *self,
range.location, range.length); range.location, range.length);
} }
- initWithCoder: aCoder // *** changed to unichar - (id) initWithCoder: (NSCoder*)aCoder
{ {
unsigned cap; unsigned cap;

View file

@ -384,11 +384,21 @@ handle_printf_atsign (FILE *stream,
- (id) initWithCharacters: (const unichar*)chars - (id) initWithCharacters: (const unichar*)chars
length: (unsigned)length length: (unsigned)length
{ {
NSZone *z = [self zone]; NSZone *z;
unichar *s = NSZoneMalloc(z, sizeof(unichar)*length); unichar *s;
if (length > 0)
{
z = [self zone];
s = NSZoneMalloc(z, sizeof(unichar)*length);
if (chars) if (chars)
memcpy(s, chars, sizeof(unichar)*length); memcpy(s, chars, sizeof(unichar)*length);
}
else
{
s = 0;
z = 0;
}
return [self initWithCharactersNoCopy: s length: length fromZone: z]; return [self initWithCharactersNoCopy: s length: length fromZone: z];
} }
@ -400,7 +410,7 @@ handle_printf_atsign (FILE *stream,
if (flag) if (flag)
return [self initWithCStringNoCopy: byteString return [self initWithCStringNoCopy: byteString
length: length length: length
fromZone: NSZoneFromPointer(byteString)]; fromZone: length?NSZoneFromPointer(byteString):0];
else else
return [self initWithCStringNoCopy: byteString return [self initWithCStringNoCopy: byteString
length: length length: length
@ -418,11 +428,24 @@ handle_printf_atsign (FILE *stream,
- (id) initWithCString: (const char*)byteString length: (unsigned)length - (id) initWithCString: (const char*)byteString length: (unsigned)length
{ {
NSZone *z = [self zone]; NSZone *z;
char *s = NSZoneMalloc(z, length); char *s;
if (length > 0)
{
z = [self zone];
s = NSZoneMalloc(z, length);
if (byteString) if (byteString)
{
memcpy(s, byteString, length); memcpy(s, byteString, length);
}
}
else
{
s = 0;
z = 0;
}
return [self initWithCStringNoCopy: s length: length fromZone: z]; return [self initWithCStringNoCopy: s length: length fromZone: z];
} }
@ -434,11 +457,21 @@ handle_printf_atsign (FILE *stream,
- (id) initWithString: (NSString*)string - (id) initWithString: (NSString*)string
{ {
NSZone *z = [self zone];
unsigned length = [string length]; unsigned length = [string length];
unichar *s = NSZoneMalloc(z, sizeof(unichar)*length); NSZone *z;
unichar *s;
if (length > 0)
{
z = [self zone];
s = NSZoneMalloc(z, sizeof(unichar)*length);
[string getCharacters: s]; [string getCharacters: s];
}
else
{
s = 0;
z = 0;
}
return [self initWithCharactersNoCopy: s return [self initWithCharactersNoCopy: s
length: length length: length
fromZone: z]; fromZone: z];
@ -581,21 +614,37 @@ handle_printf_atsign (FILE *stream,
if ((encoding==[NSString defaultCStringEncoding]) if ((encoding==[NSString defaultCStringEncoding])
|| (encoding==NSASCIIStringEncoding)) || (encoding==NSASCIIStringEncoding))
{ {
NSZone *z = fastZone(self); unsigned len=[data length];
int len=[data length]; NSZone *z;
char *s = NSZoneMalloc(z, len+1); char *s;
if (len > 0)
{
z = fastZone(self);
s = NSZoneMalloc(z, len);
[data getBytes: s]; [data getBytes: s];
}
else
{
s = 0;
z = 0;
}
return [self initWithCStringNoCopy: s length: len fromZone: z]; return [self initWithCStringNoCopy: s length: len fromZone: z];
} }
else else
{ {
NSZone *z = fastZone(self); unsigned len = [data length];
int len=[data length]; NSZone *z;
unichar *u = NSZoneMalloc(z, sizeof(unichar)*(len+1)); unichar *u;
int count; unsigned count;
const unsigned char *b=[data bytes]; const unsigned char *b;
if (len < 2)
return [self initWithCStringNoCopy: 0 length: 0 fromZone: z];
z = fastZone(self);
b=[data bytes];
u = NSZoneMalloc(z, sizeof(unichar)*(len+1));
if (encoding==NSUnicodeStringEncoding) if (encoding==NSUnicodeStringEncoding)
{ {
if ((b[0]==0xFE)&(b[1]==0xFF)) if ((b[0]==0xFE)&(b[1]==0xFF))
@ -618,9 +667,13 @@ handle_printf_atsign (FILE *stream,
{ {
NSStringEncoding enc; NSStringEncoding enc;
id d = [NSData dataWithContentsOfFile: path]; id d = [NSData dataWithContentsOfFile: path];
const unsigned char *test=[d bytes]; const unsigned char *test;
if (d == nil) return nil; if (d == nil)
return nil;
if ([d length] < 2)
return @"";
test = [d bytes];
if (test && (((test[0]==0xFF) && (test[1]==0xFE)) || ((test[1]==0xFF) && (test[0]==0xFE)))) if (test && (((test[0]==0xFF) && (test[1]==0xFE)) || ((test[1]==0xFF) && (test[0]==0xFE))))
enc = NSUnicodeStringEncoding; enc = NSUnicodeStringEncoding;
else else
@ -912,14 +965,18 @@ handle_printf_atsign (FILE *stream,
- (BOOL) isEqual: (id)anObject - (BOOL) isEqual: (id)anObject
{ {
if (anObject == self) { if (anObject == self)
{
return YES; return YES;
} }
if (anObject != nil) { if (anObject != nil)
{
Class c = fastClassOfInstance(anObject); Class c = fastClassOfInstance(anObject);
if (c != nil) { if (c != nil)
if (fastClassIsKindOfClass(c, NSString_class)) { {
if (fastClassIsKindOfClass(c, NSString_class))
{
return [self isEqualToString: anObject]; return [self isEqualToString: anObject];
} }
} }
@ -1244,54 +1301,63 @@ handle_printf_atsign (FILE *stream,
// but this will work in most cases // but this will work in most cases
- (NSString*) capitalizedString - (NSString*) capitalizedString
{ {
NSZone *z = fastZone(self); NSZone *z;
unichar *s; unichar *s;
int count=0; unsigned count = 0;
BOOL found=YES; BOOL found = YES;
int len=[self length]; unsigned len = [self length];
if (len == 0)
return self;
if (whitespce == nil) if (whitespce == nil)
setupWhitespce(); setupWhitespce();
s = NSZoneMalloc(z, sizeof(unichar)*(len+1)); z = fastZone(self);
s = NSZoneMalloc(z, sizeof(unichar)*len);
[self getCharacters: s]; [self getCharacters: s];
s[len] = (unichar)0;
while (count<len) while (count<len)
{ {
if ((*whitespceImp)(whitespce, cMemberSel, s[count])) if ((*whitespceImp)(whitespce, cMemberSel, s[count]))
{ {
count++; count++;
found=YES; found=YES;
while ((*whitespceImp)(whitespce, cMemberSel, s[count]) && (count < len)) while ((*whitespceImp)(whitespce, cMemberSel, s[count])
&& (count < len))
{
count++; count++;
}; }
}
if (found) if (found)
{ {
s[count]=uni_toupper(s[count]); s[count] = uni_toupper(s[count]);
count++; count++;
} }
else else
{ {
while (!(*whitespceImp)(whitespce, cMemberSel, s[count]) && (count < len)) while (!(*whitespceImp)(whitespce, cMemberSel, s[count])
&& (count < len))
{ {
s[count]=uni_tolower(s[count]); s[count] = uni_tolower(s[count]);
count++; count++;
}; }
}; }
found=NO; found=NO;
}; }
return AUTORELEASE([[NSString allocWithZone: NSDefaultMallocZone()] return AUTORELEASE([[NSString allocWithZone: NSDefaultMallocZone()]
initWithCharactersNoCopy: s length: len fromZone: z]); initWithCharactersNoCopy: s length: len fromZone: z]);
} }
- (NSString*) lowercaseString - (NSString*) lowercaseString
{ {
NSZone *z = fastZone(self); NSZone *z;
unichar *s; unichar *s;
unsigned count; unsigned count;
unsigned len = [self length]; unsigned len = [self length];
s = NSZoneMalloc(z, sizeof(unichar)*(len+1)); if (len == 0)
return self;
z = fastZone(self);
s = NSZoneMalloc(z, sizeof(unichar)*len);
for (count = 0; count < len; count++) for (count = 0; count < len; count++)
s[count] = uni_tolower([self characterAtIndex: count]); s[count] = uni_tolower([self characterAtIndex: count]);
return AUTORELEASE([[NSString_concrete_class return AUTORELEASE([[NSString_concrete_class
@ -1301,12 +1367,15 @@ handle_printf_atsign (FILE *stream,
- (NSString*) uppercaseString; - (NSString*) uppercaseString;
{ {
NSZone *z = fastZone(self); NSZone *z;
unichar *s; unichar *s;
unsigned count; unsigned count;
unsigned len = [self length]; unsigned len = [self length];
s = NSZoneMalloc(z, sizeof(unichar)*(len+1)); if (len == 0)
return self;
z = fastZone(self);
s = NSZoneMalloc(z, sizeof(unichar)*len);
for (count = 0; count < len; count++) for (count = 0; count < len; count++)
s[count] = uni_toupper([self characterAtIndex: count]); s[count] = uni_toupper([self characterAtIndex: count]);
return AUTORELEASE([[NSString_concrete_class return AUTORELEASE([[NSString_concrete_class
@ -1357,7 +1426,8 @@ handle_printf_atsign (FILE *stream,
range: (NSRange)aRange range: (NSRange)aRange
remainingRange: (NSRange*)leftoverRange remainingRange: (NSRange*)leftoverRange
{ {
int len, count; unsigned len;
unsigned count;
len = [self cStringLength]; len = [self cStringLength];
GS_RANGE_CHECK(aRange, len); GS_RANGE_CHECK(aRange, len);
@ -1380,8 +1450,8 @@ handle_printf_atsign (FILE *stream,
leftoverRange->length = aRange.length - maxLength; leftoverRange->length = aRange.length - maxLength;
} }
} }
count=0; count = 0;
while (count<len) while (count < len)
{ {
buffer[count]=unitochar([self characterAtIndex: aRange.location + count]); buffer[count]=unitochar([self characterAtIndex: aRange.location + count]);
count++; count++;
@ -1465,6 +1535,9 @@ handle_printf_atsign (FILE *stream,
int count=0; int count=0;
int len = [self length]; int len = [self length];
if (len == 0)
return [NSData data];
if ((encoding==NSASCIIStringEncoding) if ((encoding==NSASCIIStringEncoding)
|| (encoding==NSISOLatin1StringEncoding) || (encoding==NSISOLatin1StringEncoding)
|| (encoding==NSNEXTSTEPStringEncoding) || (encoding==NSNEXTSTEPStringEncoding)
@ -2167,7 +2240,7 @@ handle_printf_atsign (FILE *stream,
return RETAIN(self); return RETAIN(self);
} }
- mutableCopyWithZone: (NSZone*)zone - (id) mutableCopyWithZone: (NSZone*)zone
{ {
return [[[[self class] _mutableConcreteClass] allocWithZone: zone] return [[[[self class] _mutableConcreteClass] allocWithZone: zone]
initWithString: self]; initWithString: self];
@ -2175,12 +2248,12 @@ handle_printf_atsign (FILE *stream,
/* NSCoding Protocol */ /* NSCoding Protocol */
- (void) encodeWithCoder: anEncoder - (void) encodeWithCoder: (NSCoder*)anEncoder
{ {
[self subclassResponsibility: _cmd]; [self subclassResponsibility: _cmd];
} }
- initWithCoder: aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
[self subclassResponsibility: _cmd]; [self subclassResponsibility: _cmd];
return self; return self;
@ -2266,7 +2339,7 @@ handle_printf_atsign (FILE *stream,
@implementation NSMutableString @implementation NSMutableString
+ allocWithZone: (NSZone*)z + (id) allocWithZone: (NSZone*)z
{ {
if ([self class] == [NSMutableString class]) if ([self class] == [NSMutableString class])
return NSAllocateObject([self _mutableConcreteClass], 0, z); return NSAllocateObject([self _mutableConcreteClass], 0, z);
@ -2316,7 +2389,7 @@ handle_printf_atsign (FILE *stream,
// Initializing Newly Allocated Strings // Initializing Newly Allocated Strings
- initWithCapacity: (unsigned)capacity - (id) initWithCapacity: (unsigned)capacity
{ {
[self subclassResponsibility: _cmd]; [self subclassResponsibility: _cmd];
return self; return self;