Follow better the 'Apple Create Rule' for our variables. This fixes a memory leak. Closes #240
This commit is contained in:
parent
4ff3cfd56c
commit
22e8549e7e
1 changed files with 4 additions and 6 deletions
|
@ -81,22 +81,21 @@ int Settings::getNumberOfNodes(Node type) const {
|
|||
|
||||
int Settings::getNodeId(Node type, int intNodeIndex) const {
|
||||
CFArrayRef cfarray = CFPreferencesCopyKeyList( d->app_ID, d->userName, d->hostName );
|
||||
if (!cfarray) return 0;
|
||||
if (!cfarray) {
|
||||
return 0;
|
||||
}
|
||||
CFIndex size = CFArrayGetCount( cfarray );
|
||||
int index = 0;
|
||||
int id = 0;
|
||||
for (CFIndex k = 0; k < size; ++k) {
|
||||
CFStringRef key = (CFStringRef) CFArrayGetValueAtIndex(cfarray, k);
|
||||
if (!CFStringHasSuffix( key, CFSTR(".name") )) {
|
||||
CFRelease( key );
|
||||
continue;
|
||||
}
|
||||
if ( type == Device && !CFStringHasPrefix(key, CFSTR("devices.")) ) {
|
||||
CFRelease( key );
|
||||
continue;
|
||||
}
|
||||
if ( type == Controller && !CFStringHasPrefix(key, CFSTR("controllers.")) ) {
|
||||
CFRelease( key );
|
||||
continue;
|
||||
}
|
||||
if (index == intNodeIndex) {
|
||||
|
@ -123,13 +122,12 @@ int Settings::getNodeId(Node type, int intNodeIndex) const {
|
|||
}
|
||||
free(cp);
|
||||
|
||||
CFRelease(key);
|
||||
CFRelease(split);
|
||||
CFRelease(cfid);
|
||||
break;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
CFRelease(cfarray);
|
||||
return id;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue