From b25748e37af88ed4555c929e6e71a1941bf0474b Mon Sep 17 00:00:00 2001 From: mccallum Date: Sun, 19 Nov 1995 20:29:39 +0000 Subject: [PATCH] ([NSString +allocWithZone:]): New method. ([NSString +stringWithCString:byteString]): Use it. ([NSString +stringWithCString:length:]): Likewise. ([NSString +stringWithFormat:]): Likewise. ([NSString +stringWithFormat:arguments:]): Likewise. ([NSMutableString +allocWithZone:]): New method. ([NSMutableString +stringWithCapacity:]): Use it. ([NSMutableString +stringWithCString:length:]): Likewise. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@676 72102866-910b-0410-8b05-ffd578937521 --- Source/NSString.m | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Source/NSString.m b/Source/NSString.m index 999bb5dff..0b5bda5a4 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -105,6 +105,11 @@ static Class NSMutableString_c_concrete_class; } } ++ allocWithZone: (NSZone*)z +{ + return NSAllocateObject([self _concreteClass], 0, z); +} + // Creating Temporary Strings + (NSString*) localizedStringWithFormat: (NSString*) format, ... @@ -115,14 +120,14 @@ static Class NSMutableString_c_concrete_class; + (NSString*) stringWithCString: (const char*) byteString { - return [[[[self _concreteCClass] alloc] initWithCString:byteString] + return [[[self alloc] initWithCString:byteString] autorelease]; } + (NSString*) stringWithCString: (const char*)byteString length: (unsigned int)length { - return [[[[self _concreteCClass] alloc] + return [[[self alloc] initWithCString:byteString length:length] autorelease]; } @@ -140,7 +145,7 @@ static Class NSMutableString_c_concrete_class; id ret; va_start(ap, format); - ret = [[[[self _concreteClass] alloc] initWithFormat:format arguments:ap] + ret = [[[self alloc] initWithFormat:format arguments:ap] autorelease]; va_end(ap); return ret; @@ -149,7 +154,7 @@ static Class NSMutableString_c_concrete_class; + (NSString*) stringWithFormat: (NSString*)format arguments: (va_list)argList { - return [[[[self _concreteClass] alloc] + return [[[self alloc] initWithFormat:format arguments:argList] autorelease]; } @@ -929,6 +934,11 @@ static Class NSMutableString_c_concrete_class; @implementation NSMutableString ++ allocWithZone: (NSZone*)z +{ + return NSAllocateObject([self _mutableConcreteClass], 0, z); +} + /* xxx This method may be removed in future. */ - (void) setCString: (const char *)byteString length: (unsigned)length { @@ -949,7 +959,7 @@ static Class NSMutableString_c_concrete_class; + (NSMutableString*) stringWithCapacity:(unsigned)capacity { - return [[[[self _mutableConcreteClass] alloc] initWithCapacity:capacity] + return [[[self alloc] initWithCapacity:capacity] autorelease]; } @@ -971,7 +981,7 @@ static Class NSMutableString_c_concrete_class; + (NSString*) stringWithCString: (const char*)bytes length:(unsigned)length { - id n = [[[self _mutableConcreteCClass] alloc] initWithCapacity:length]; + id n = [[self alloc] initWithCapacity:length]; [n setCString:bytes length:length]; return n; }