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 {
|
int Settings::getNodeId(Node type, int intNodeIndex) const {
|
||||||
CFArrayRef cfarray = CFPreferencesCopyKeyList( d->app_ID, d->userName, d->hostName );
|
CFArrayRef cfarray = CFPreferencesCopyKeyList( d->app_ID, d->userName, d->hostName );
|
||||||
if (!cfarray) return 0;
|
if (!cfarray) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
CFIndex size = CFArrayGetCount( cfarray );
|
CFIndex size = CFArrayGetCount( cfarray );
|
||||||
int index = 0;
|
int index = 0;
|
||||||
int id = 0;
|
int id = 0;
|
||||||
for (CFIndex k = 0; k < size; ++k) {
|
for (CFIndex k = 0; k < size; ++k) {
|
||||||
CFStringRef key = (CFStringRef) CFArrayGetValueAtIndex(cfarray, k);
|
CFStringRef key = (CFStringRef) CFArrayGetValueAtIndex(cfarray, k);
|
||||||
if (!CFStringHasSuffix( key, CFSTR(".name") )) {
|
if (!CFStringHasSuffix( key, CFSTR(".name") )) {
|
||||||
CFRelease( key );
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( type == Device && !CFStringHasPrefix(key, CFSTR("devices.")) ) {
|
if ( type == Device && !CFStringHasPrefix(key, CFSTR("devices.")) ) {
|
||||||
CFRelease( key );
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( type == Controller && !CFStringHasPrefix(key, CFSTR("controllers.")) ) {
|
if ( type == Controller && !CFStringHasPrefix(key, CFSTR("controllers.")) ) {
|
||||||
CFRelease( key );
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (index == intNodeIndex) {
|
if (index == intNodeIndex) {
|
||||||
|
@ -123,13 +122,12 @@ int Settings::getNodeId(Node type, int intNodeIndex) const {
|
||||||
}
|
}
|
||||||
free(cp);
|
free(cp);
|
||||||
|
|
||||||
CFRelease(key);
|
|
||||||
CFRelease(split);
|
CFRelease(split);
|
||||||
CFRelease(cfid);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
CFRelease(cfarray);
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue