obscurestar avatar obscurestar committed 05202b7

Fixed small one-time memory leaks.

Comments (0)

Files changed (2)

indra/llvfs/llvfs_objc.mm

 
 std::string* getSystemTempFolder()
 {
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     NSString * tempDir = NSTemporaryDirectory();
     if (tempDir == nil)
         tempDir = @"/tmp";
-    return ( new std::string([tempDir UTF8String]) );
+    std::string *result = ( new std::string([tempDir UTF8String]) );
+    [pool release];
+    
+    return result;
 }
 
 //findSystemDirectory scoped exclusively to this file. 
 std::string* findSystemDirectory(NSSearchPathDirectory searchPathDirectory,
                                    NSSearchPathDomainMask domainMask)
 {
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    
     std::string *result;
     NSString *path = nil;
     
         
         result = new std::string([path UTF8String]);        
     }
+    [pool release];
     return result;
 }
 
 std::string* getSystemExecutableFolder()
 {
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
     NSString *bundlePath = [[NSBundle mainBundle] executablePath];
-    return (new std::string([bundlePath UTF8String]));  
+    std::string *result = (new std::string([bundlePath UTF8String]));  
+    [pool release];
+
+    return result;
 }
 
 std::string* getSystemResourceFolder()
 {
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
     NSString *bundlePath = [[NSBundle mainBundle] resourcePath];
-    return (new std::string([bundlePath UTF8String]));
+    std::string *result = (new std::string([bundlePath UTF8String]));
+    [pool release];
+    
+    return result;
 }
 
 std::string* getSystemCacheFolder()

indra/mac_updater/MacUpdaterAppDelegate.mm

 
 bool copyDir(const std::string& src_dir, const std::string& dest_dir)
 {
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
     NSString* file = [NSString stringWithCString:src_dir.c_str() 
                                          encoding:[NSString defaultCStringEncoding]];
     NSString* toParent = [NSString stringWithCString:dest_dir.c_str() 
     if (!result) {
         NSLog(@"Error during copy: %@", [error localizedDescription]);
     }
+    [pool release];
+    
     return result;
 }
 
 
 bool isDirWritable(const std::string& dir_name)
 {
-    
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
     NSString *fullPath = [NSString stringWithCString:dir_name.c_str() 
                                             encoding:[NSString defaultCStringEncoding]];
 
     NSFileManager *fm = [NSFileManager defaultManager];
     bool result = [fm isWritableFileAtPath:fullPath];
+    [pool release];
     
 	return result;
 }
 
 std::string* getUserTrashFolder()
 {
+    std::string *result;
+    
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
     NSString *trash_str=[NSHomeDirectory() stringByAppendingPathComponent:@".Trash"];
-    return NSToString( trash_str );
+    
+    result = NSToString( trash_str );
+    
+    [pool release];
+    return result;
 
 }
 
 bool isFSRefViewerBundle(const std::string& targetURL)
 {
 	bool result = false;
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
     NSString *fullPath = [NSString stringWithCString:targetURL.c_str() 
                                             encoding:[NSString defaultCStringEncoding]];
     NSBundle *targetBundle = [NSBundle bundleWithPath:fullPath];
         std::cout << "Target bundle ID mismatch." << std::endl;
     }
     
+    [pool release];
+    
 	return result;
 }
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.