mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Make sure copied substrings are independent of the substring parent.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@8390 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
012ba919ad
commit
dcbe706006
1 changed files with 23 additions and 0 deletions
|
@ -1798,6 +1798,17 @@ transmute(ivars self, NSString *aString)
|
|||
* a section of a parent constant string class.
|
||||
*/
|
||||
@implementation GSCSubString
|
||||
/*
|
||||
* Assume that a copy should be a new string, never just a retained substring.
|
||||
*/
|
||||
- (id) copyWithZone: (NSZone*)z
|
||||
{
|
||||
NSString *obj;
|
||||
|
||||
obj = (NSString*)NSAllocateObject(GSCInlineStringClass, _count, z);
|
||||
obj = [obj initWithCString: _contents.c length: _count];
|
||||
return obj;
|
||||
}
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_parent);
|
||||
|
@ -2083,6 +2094,18 @@ transmute(ivars self, NSString *aString)
|
|||
* into a section of a parent constant string class.
|
||||
*/
|
||||
@implementation GSUnicodeSubString
|
||||
/*
|
||||
* Assume that a copy should be a new string, never just a retained substring.
|
||||
*/
|
||||
- (id) copyWithZone: (NSZone*)z
|
||||
{
|
||||
NSString *obj;
|
||||
|
||||
obj = (NSString*)NSAllocateObject(GSUnicodeInlineStringClass,
|
||||
_count*sizeof(unichar), z);
|
||||
obj = [obj initWithCharacters: _contents.u length: _count];
|
||||
return obj;
|
||||
}
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_parent);
|
||||
|
|
Loading…
Reference in a new issue