Simplify NSString subclassing

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@7954 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2000-10-31 19:07:35 +00:00
parent 8894c52b34
commit 780868f1a5
4 changed files with 202 additions and 30 deletions

View file

@ -404,7 +404,7 @@ handle_printf_atsign (FILE *stream,
// Initializing Newly Allocated Strings
/* This is the designated initializer for Unicode Strings. */
/* This is the designated initializer. */
- (id) initWithCharactersNoCopy: (unichar*)chars
length: (unsigned)length
freeWhenDone: (BOOL)flag
@ -468,12 +468,19 @@ handle_printf_atsign (FILE *stream,
return self;
}
/* This is the designated initializer for CStrings. */
- (id) initWithCStringNoCopy: (char*)byteString
length: (unsigned)length
freeWhenDone: (BOOL)flag
{
[self subclassResponsibility: _cmd];
unichar *buf;
buf = (unichar*)NSZoneMalloc(GSObjCZone(self), sizeof(unichar)*length);
length = encode_strtoustr(buf, byteString, length, _DefaultStringEncoding);
if (flag == YES && byteString != 0)
{
NSZoneFree(NSZoneFromPointer(byteString), byteString);
}
self = [self initWithCharactersNoCopy: buf length: length freeWhenDone: YES];
return self;
}