mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-01 09:02:01 +00:00
([NSString -initWithCString:length:]): Handle case of NULL cString.
([NSString -initWithCString:]): Likewise. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@740 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7a7174faef
commit
7deb5b6173
1 changed files with 5 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
||||||
/* Implementation of GNUSTEP string class
|
/* Implementation of GNUSTEP string class
|
||||||
Copyright (C) 1995 Free Software Foundation, Inc.
|
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||||
Date: January 1995
|
Date: January 1995
|
||||||
|
@ -168,7 +168,8 @@ static Class NSMutableString_c_concrete_class;
|
||||||
|
|
||||||
- (id) initWithCString: (const char*)byteString
|
- (id) initWithCString: (const char*)byteString
|
||||||
{
|
{
|
||||||
return [self initWithCString:byteString length:strlen(byteString)];
|
return [self initWithCString:byteString
|
||||||
|
length:(byteString ? strlen(byteString) : 0)];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithCString: (const char*)byteString
|
- (id) initWithCString: (const char*)byteString
|
||||||
|
@ -176,7 +177,8 @@ static Class NSMutableString_c_concrete_class;
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
OBJC_MALLOC(s, char, length+1);
|
OBJC_MALLOC(s, char, length+1);
|
||||||
memcpy(s, byteString, length);
|
if (byteString)
|
||||||
|
memcpy(s, byteString, length);
|
||||||
s[length] = '\0';
|
s[length] = '\0';
|
||||||
return [self initWithCStringNoCopy:s length:length freeWhenDone:YES];
|
return [self initWithCStringNoCopy:s length:length freeWhenDone:YES];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue