From cbde3a7c1bfb6afd17518b92e6b4f6dd244b432a Mon Sep 17 00:00:00 2001 From: Tomaz Kragelj Date: Tue, 15 Sep 2009 12:25:47 +0200 Subject: [PATCH] Fixed several memory leaks (say hello to static analizer). --- Systemator.m | 2 +- XMLOutputGenerator.m | 5 +++++ appledoc.xcodeproj/project.pbxproj | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Systemator.m b/Systemator.m index 6ae5511b..e7382e54 100644 --- a/Systemator.m +++ b/Systemator.m @@ -282,7 +282,7 @@ + (NSMutableArray*) linesFromContentsOfFile:(NSString*) filename + (void) writeLines:(NSArray*) lines toFile:(NSString*) filename { // Generate the string containing all lines. - NSMutableString* string = [[NSMutableString alloc] init]; + NSMutableString* string = [NSMutableString string]; for (NSString* line in lines) { [string appendString:line]; diff --git a/XMLOutputGenerator.m b/XMLOutputGenerator.m index 538ec47a..4ad4b176 100644 --- a/XMLOutputGenerator.m +++ b/XMLOutputGenerator.m @@ -332,6 +332,7 @@ - (void) mergeCleanCategoriesToKnownObjects [nameNode setStringValue:classSectionName]; } [classSectionsNode addChild:classSectionNode]; + [classSectionNode release]; } } else @@ -350,6 +351,7 @@ - (void) mergeCleanCategoriesToKnownObjects { NSXMLElement* classMemberNode = [memberNode copy]; [sectionNode addChild:classMemberNode]; + [classMemberNode release]; } // Append the section data to the main class document. @@ -380,6 +382,7 @@ - (void) mergeCleanCategoriesToKnownObjects index); NSXMLElement* insertedNode = [categoryFileNode copy]; [parentNode insertChild:insertedNode atIndex:index + 1]; + [insertedNode release]; index++; } } @@ -484,6 +487,7 @@ - (void) createCleanIndexDocumentationFile // Save the markup. NSError* error = nil; NSData* markupData = [document XMLDataWithOptions:NSXMLNodePrettyPrint]; + [document release]; NSString* filename = [self outputBasePath]; filename = [filename stringByAppendingPathComponent:[self outputIndexFilename]]; if (![markupData writeToFile:filename options:0 error:&error]) @@ -601,6 +605,7 @@ - (void) createCleanHierarchyDocumentationFile // Save the markup. NSError* error = nil; NSData* markupData = [document XMLDataWithOptions:NSXMLNodePrettyPrint]; + [document release]; NSString* filename = [self outputBasePath]; filename = [filename stringByAppendingPathComponent:[self outputHierarchyFilename]]; if (![markupData writeToFile:filename options:0 error:&error]) diff --git a/appledoc.xcodeproj/project.pbxproj b/appledoc.xcodeproj/project.pbxproj index fa4de19c..a087e158 100644 --- a/appledoc.xcodeproj/project.pbxproj +++ b/appledoc.xcodeproj/project.pbxproj @@ -383,6 +383,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; ONLY_ACTIVE_ARCH = YES; PREBINDING = NO; + RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = macosx10.5; }; name = Debug; @@ -396,6 +397,7 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; PREBINDING = NO; + RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = macosx10.5; }; name = Release;