gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: big memory leak in GSString


From: Pirmin Braun
Subject: Re: big memory leak in GSString
Date: Tue, 8 Jan 2013 16:35:23 +0100

Am Tue, 8 Jan 2013 14:51:07 +0000
schrieb David Chisnall <address@hidden> :

> On 8 Jan 2013, at 14:41, Pirmin Braun wrote:
> 
> >        NSString *s1 = [[a oai:i]copy];
> 
> For an immutable string, -copy just calls retain.  If you want to actually 
> copy the string, do something like:
> 
> NSString *s1 = [NSString stringWithUTF8String: [old UTF8String]];
> 
> (for better performance, you might want to use getCharacters:range: and a 
> temporary buffer, so that the old string doesn't have to create a new 
> autoreleased buffer).
> 
> David
> 
> -- Sent from my STANTEC-ZEBRA
> 

ok, changed it like this:
    NSArray *a = [self componentsSeparatedByString:s];
    NSMutableArray *ma = [NSMutableArray arrayWithCapacity:[a count]];
    int i,j;

    // deep copy of a
    for(i=0,j=[a count];i<j;i++){
        [ma addObject:[NSString stringWithUTF8String:[[a oai:i]UTF8String]]];
    }
    return [NSArray arrayWithArray:ma]; // immutable

but also no difference; I give up. For the moment.
Thanks to all who helped.

-- 
Pirmin Braun - IntarS Unternehmenssoftware GmbH - Sinziger Str. 29a - 53424 
Remagen
+49 2642 308288 +49 174 9747584 - skype:pirminb www.intars.de  address@hidden 
intars.sourceforge.net
Geschäftsführer: Pirmin Braun, Ralf Engelhardt Registergericht: Amtsgericht 
Coburg HRB3136



reply via email to

[Prev in Thread] Current Thread [Next in Thread]