Fix over-release.

Add autorelease around the Preferences methods.
This commit is contained in:
C.W. Betts 2017-06-03 22:53:10 -06:00 committed by sa666666
parent 1ecb8852de
commit b489a61e03
2 changed files with 11 additions and 6 deletions

View File

@ -45,23 +45,26 @@ static Preferences *sharedInstance = nil;
- (id)init
{
defaults = [NSUserDefaults standardUserDefaults];
sharedInstance = self;
if (self = [super init]) {
defaults = [NSUserDefaults standardUserDefaults];
sharedInstance = self;
}
return(self);
}
- (void)setString:(const char *)key : (const char *)value
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString* theKey = [NSString stringWithCString:key encoding:NSASCIIStringEncoding];
NSString* theValue = [NSString stringWithCString:value encoding:NSASCIIStringEncoding];
[defaults setObject:theValue forKey:theKey];
[theKey release];
[theValue release];
[pool release];
}
- (void)getString:(const char *)key : (char *)value : (int)size
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString* theKey = [NSString stringWithCString:key encoding:NSASCIIStringEncoding];
NSString* theValue = [defaults objectForKey:theKey];
if (theValue != nil)
@ -69,13 +72,14 @@ static Preferences *sharedInstance = nil;
else
value[0] = 0;
[theKey release];
[theValue release];
[pool release];
}
- (void)save
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[defaults synchronize];
[pool release];
}
@end

View File

@ -1283,6 +1283,7 @@
name = "«PROJECTNAMEASXML»";
sourceTree = "<group>";
tabWidth = 2;
usesTabs = 0;
};
29B97315FDCFA39411CA2CEA /* Other Sources */ = {
isa = PBXGroup;