0

ie:

boolRef = (CFBooleanRef)CFDictionaryGetValue(descriptionDictionary, kDADiskDescriptionMediaRemovableKey);
if (boolRef) {
    CFRelease(boolRef); // do i need this code?
}
ABBAPOH
  • 11
  • 2

1 Answers1

2

First read the Memory Management Programming Guide for Core Foundation. The answer is no, because of the Create Rule. CFDictionaryGetValue() does not include the words "Create" or "Copy."

Note that CFRelease() in this case is not just unneeded, it is incorrect and will lead to an over-release crash.

Rob Napier
  • 286,113
  • 34
  • 456
  • 610
  • 1
    There are precious few cases where releasing *is* optional. In almost every case, either you need to do it or you need to *not* do it. – Chuck Nov 15 '10 at 18:45
  • Thank you. I've read this before asking, but in the example i used they were released, so i was not sure. – ABBAPOH Nov 15 '10 at 18:51