Skip to content

Commit

Permalink
CFRelease CFString objects
Browse files Browse the repository at this point in the history
Core Foundation functions have names that indicate when you own a returned object:
Object-creation functions that have "Create" embedded in the name;
Object-duplication functions that have "Copy" embedded in the name.
If you own an object, it is your responsibility to relinquish ownership (using CFRelease) when you have finished with it.
  • Loading branch information
akirashirosawa authored May 4, 2020
1 parent 54afa14 commit 5ed7427
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/translations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,10 @@ bool localized_comparator::operator()( const std::string &l, const std::string &
kCFStringEncodingUTF8, kCFAllocatorNull );
CFStringRef rr = CFStringCreateWithCStringNoCopy( kCFAllocatorDefault, r.c_str(),
kCFStringEncodingUTF8, kCFAllocatorNull );
return CFStringCompare( lr, rr, kCFCompareLocalized ) < 0;
bool result = CFStringCompare( lr, rr, kCFCompareLocalized ) < 0;
CFRelease( lr );
CFRelease( rr );
return result;
#endif
return std::locale()( l, r );
}

0 comments on commit 5ed7427

Please sign in to comment.