mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
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:
parent
8894c52b34
commit
780868f1a5
4 changed files with 202 additions and 30 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue