Ejemplo n.º 1
0
static void __CFDataDeallocate(CFTypeRef cf) {
    CFMutableDataRef data = (CFMutableDataRef)cf;
    if (!__CFDataBytesInline(data) && !__CFDataGetInfoBit(data, __kCFDontDeallocate)) {
        CFAllocatorRef deallocator = data->_bytesDeallocator;
        if (deallocator != NULL) {
            _CFAllocatorDeallocateGC(deallocator, data->_bytes);
            CFRelease(deallocator);
            data->_bytes = NULL;
        } else {
            if (__CFDataUseAllocator(data)) {
                _CFAllocatorDeallocateGC(__CFGetAllocator(data), data->_bytes);
            } else if (!__CFDataAllocatesCollectable(data) && data->_bytes) {
                free(data->_bytes);
            }
            data->_bytes = NULL;
        }
    }
}
CF_INLINE Boolean __CFDataAllocatesCollectable(CFDataRef data) {return __CFDataGetInfoBit(data, __kCFAllocatesCollectable);}
CF_INLINE Boolean __CFDataUseAllocator(CFDataRef data) {return __CFDataGetInfoBit(data, __kCFUseAllocator);}
CF_INLINE Boolean __CFDataBytesInline(CFDataRef data) {return __CFDataGetInfoBit(data, __kCFBytesInline);}
CF_INLINE Boolean __CFDataIsGrowable(CFDataRef data) {return __CFDataGetInfoBit(data, __kCFGrowable);}