leak fixing

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32035 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2011-02-10 12:11:03 +00:00
parent 67df51138c
commit f3a58fb845
10 changed files with 36 additions and 18 deletions

View file

@ -1,3 +1,15 @@
2011-02-10 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSSpellServer.m: Avoid compiler warning.
* Source/NSPathUtilities.m:
* Source/NSMessagePortNameServer.m:
* Source/NSKeyValueObserving.m:
* Source/NSURLProtocol.m:
* Source/NSString.m:
* Source/NSNumberFormatter.m:
* Source/NSXMLParser.m:
Fix memory leaks
2011-02-10 11:02 David Chisnall <theraven@gna.org> 2011-02-10 11:02 David Chisnall <theraven@gna.org>
* libs/base/trunk/Headers/Additions/GNUstepBase/GSMime.h, * libs/base/trunk/Headers/Additions/GNUstepBase/GSMime.h,

View file

@ -359,7 +359,7 @@ static NSString *newKey(SEL _cmd)
u = uni_tolower(u); u = uni_tolower(u);
tmp = [[NSString alloc] initWithCharacters: &u length: 1]; tmp = [[NSString alloc] initWithCharacters: &u length: 1];
[m replaceCharactersInRange: NSMakeRange(0, 1) withString: tmp]; [m replaceCharactersInRange: NSMakeRange(0, 1) withString: tmp];
RELEASE(tmp); [tmp release];
key = m; key = m;
} }
return key; return key;
@ -455,6 +455,7 @@ replacementForClass(Class c)
tmp = [[NSString alloc] initWithCharacters: &u length: 1]; tmp = [[NSString alloc] initWithCharacters: &u length: 1];
a[0] = [NSString stringWithFormat: @"set%@%@:", tmp, suffix]; a[0] = [NSString stringWithFormat: @"set%@%@:", tmp, suffix];
a[1] = [NSString stringWithFormat: @"_set%@%@:", tmp, suffix]; a[1] = [NSString stringWithFormat: @"_set%@%@:", tmp, suffix];
[tmp release];
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
{ {
/* /*

View file

@ -472,7 +472,9 @@ static void clean_up_names(void)
RELEASE(a); RELEASE(a);
} }
[a addObject: [name copy]]; name = [name copy];
[a addObject: name];
[name release];
[serverLock unlock]; [serverLock unlock];
[dl unlock]; [dl unlock];

View file

@ -950,7 +950,8 @@ static NSUInteger _defaultBehavior = 0;
intPartRange.length++; intPartRange.length++;
} }
} }
intPad = [[useFormat substringWithRange: intPartRange] mutableCopy]; intPad = [[[useFormat substringWithRange: intPartRange]
mutableCopy] autorelease];
[intPad replaceOccurrencesOfString: defaultThousandsSeparator [intPad replaceOccurrencesOfString: defaultThousandsSeparator
withString: @"" withString: @""
options: 0 options: 0

View file

@ -1400,8 +1400,8 @@ ParseConfigurationFile(NSString *fileName, NSMutableDictionary *dict,
if (wantVal == YES) if (wantVal == YES)
{ {
[dict setObject: @"" forKey: key]; [dict setObject: @"" forKey: key];
DESTROY(key);
} }
DESTROY(key);
NSZoneFree(NSDefaultMallocZone(), src); NSZoneFree(NSDefaultMallocZone(), src);
NSZoneFree(NSDefaultMallocZone(), dst); NSZoneFree(NSDefaultMallocZone(), dst);
return YES; return YES;

View file

@ -44,6 +44,8 @@ NSString *const NSGrammarRange = @"NSGrammarRange";
NSString *const NSGrammarUserDescription = @"NSGrammarUserDescription"; NSString *const NSGrammarUserDescription = @"NSGrammarUserDescription";
NSString *const NSGrammarCorrections = @"NSGrammarCorrections"; NSString *const NSGrammarCorrections = @"NSGrammarCorrections";
static NSConnection *spellServerConnection = nil;
/* User dictionary location */ /* User dictionary location */
static NSString *GNU_UserDictionariesDir = @"Dictionaries"; static NSString *GNU_UserDictionariesDir = @"Dictionaries";
@ -111,7 +113,6 @@ GSSpellServerName(NSString *vendor, NSString *language)
byVendor: (NSString *)vendor byVendor: (NSString *)vendor
{ {
NSString *serverName = GSSpellServerName(vendor, language); NSString *serverName = GSSpellServerName(vendor, language);
NSConnection *connection = nil;
BOOL result = NO; BOOL result = NO;
if (serverName == nil) if (serverName == nil)
@ -119,12 +120,11 @@ GSSpellServerName(NSString *vendor, NSString *language)
return NO; return NO;
} }
connection = [[NSConnection alloc] init]; spellServerConnection = [[NSConnection alloc] init];
if (connection) if (spellServerConnection)
{ {
IF_NO_GC(RETAIN(connection);) [spellServerConnection setRootObject: self];
[connection setRootObject: self]; result = [spellServerConnection registerName: serverName];
result = [connection registerName: serverName];
} }
return result; return result;

View file

@ -125,6 +125,7 @@ static SEL cMemberSel = 0;
#define IS_BIT_SET(a,i) ((((a) & (1<<(i)))) > 0) #define IS_BIT_SET(a,i) ((((a) & (1<<(i)))) > 0)
static NSData *whitespaceBitmap;
static unsigned const char *whitespaceBitmapRep = NULL; static unsigned const char *whitespaceBitmapRep = NULL;
#define GS_IS_WHITESPACE(X) IS_BIT_SET(whitespaceBitmapRep[(X)/8], (X) % 8) #define GS_IS_WHITESPACE(X) IS_BIT_SET(whitespaceBitmapRep[(X)/8], (X) % 8)
@ -133,7 +134,6 @@ static void setupWhitespace(void)
if (whitespaceBitmapRep == NULL) if (whitespaceBitmapRep == NULL)
{ {
NSCharacterSet *whitespace; NSCharacterSet *whitespace;
NSData *bitmap;
/* /*
We can not use whitespaceAndNewlineCharacterSet here as this would lead We can not use whitespaceAndNewlineCharacterSet here as this would lead
@ -143,8 +143,8 @@ static void setupWhitespace(void)
whitespace = [NSCharacterSet characterSetWithCharactersInString: whitespace = [NSCharacterSet characterSetWithCharactersInString:
@" \t\r\n\f\b"]; @" \t\r\n\f\b"];
bitmap = RETAIN([whitespace bitmapRepresentation]); whitespaceBitmap = RETAIN([whitespace bitmapRepresentation]);
whitespaceBitmapRep = [bitmap bytes]; whitespaceBitmapRep = [whitespaceBitmap bytes];
} }
} }

View file

@ -669,7 +669,7 @@ static NSURLProtocol *placeholder = nil;
{ {
NSMutableURLRequest *request; NSMutableURLRequest *request;
request = [this->request mutableCopy]; request = [[this->request mutableCopy] autorelease];
[request setURL: url]; [request setURL: url];
[this->client URLProtocol: self [this->client URLProtocol: self
wasRedirectedToRequest: request wasRedirectedToRequest: request
@ -922,7 +922,7 @@ static NSURLProtocol *placeholder = nil;
{ {
NSMutableURLRequest *request; NSMutableURLRequest *request;
request = [this->request mutableCopy]; request = [[this->request mutableCopy] autorelease];
[request setURL: url]; [request setURL: url];
[this->client URLProtocol: self [this->client URLProtocol: self
wasRedirectedToRequest: request wasRedirectedToRequest: request

View file

@ -759,7 +759,8 @@ static SEL foundIgnorableSel;
NSString *tmp; NSString *tmp;
tmp = [[NSString alloc] initWithData: data encoding: enc]; tmp = [[NSString alloc] initWithData: data encoding: enc];
data = [[tmp dataUsingEncoding: NSUTF8StringEncoding] retain]; this->data
= [[tmp dataUsingEncoding: NSUTF8StringEncoding] retain];
[tmp release]; [tmp release];
} }
this->tagPath = [[NSMutableArray alloc] init]; this->tagPath = [[NSMutableArray alloc] init];
@ -1821,6 +1822,7 @@ NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes);
c = cget(); c = cget();
if (c != '>') if (c != '>')
{ {
[attributes release];
return [self _parseError: @"<tag/ is missing the >" return [self _parseError: @"<tag/ is missing the >"
code: NSXMLParserGTRequiredError]; code: NSXMLParserGTRequiredError];
} }

View file

@ -874,7 +874,7 @@ static int verbose = 0;
NSString *filename; NSString *filename;
e = [HTMLDirectoryEnumerator alloc]; e = [HTMLDirectoryEnumerator alloc];
e = [e initWithBasePath: pathOnDisk]; e = [[e initWithBasePath: pathOnDisk] autorelease];
[e setReturnsAbsolutePaths: YES]; [e setReturnsAbsolutePaths: YES];
while ((filename = [e nextObject]) != nil) while ((filename = [e nextObject]) != nil)
@ -1056,7 +1056,7 @@ build_relocation_table_for_directory (NSString *dir)
IF_NO_GC ([relocationTable autorelease];) IF_NO_GC ([relocationTable autorelease];)
e = [HTMLDirectoryEnumerator alloc]; e = [HTMLDirectoryEnumerator alloc];
e = [e initWithBasePath: dir]; e = [[e initWithBasePath: dir] autorelease];
/* The relocation table for a directory is relative to the /* The relocation table for a directory is relative to the
directory top, so that the whole directory can be moved directory top, so that the whole directory can be moved
around without having to regenerate the .htmlink file. */ around without having to regenerate the .htmlink file. */