CFMutableDataRef CFDataCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFDataRef data) { // Do not allow magic allocator for now for mutable datas, because it // isn't remembered for proper handling later when growth of the buffer // has to occur. Boolean wasMagic = (0); CFMutableDataRef r = (CFMutableDataRef) __CFDataInit(allocator, (0 == capacity) ? kCFMutable : kCFFixedMutable, capacity, CFDataGetBytePtr(data), CFDataGetLength(data), NULL); if (wasMagic) CFMakeCollectable(r); return r; }
CFMutableDataRef CFDataCreateMutable(CFAllocatorRef allocator, CFIndex capacity) { // Do not allow magic allocator for now for mutable datas, because it // isn't remembered for proper handling later when growth of the buffer // has to occur. Boolean wasMagic = _CFAllocatorIsGCRefZero(allocator); if (0 == capacity) allocator = _CFConvertAllocatorToNonGCRefZeroEquivalent(allocator); CFMutableDataRef r = (CFMutableDataRef)__CFDataInit(allocator, (0 == capacity) ? kCFMutable : kCFFixedMutable, capacity, NULL, 0, NULL); if (wasMagic) CFMakeCollectable(r); return r; }
CFDataRef CFDataCreateCopy(CFAllocatorRef allocator, CFDataRef data) { CFIndex length = CFDataGetLength(data); return __CFDataInit(allocator, kCFImmutable, length, CFDataGetBytePtr(data), length, NULL); }
CFDataRef CFDataCreateWithBytesNoCopy(CFAllocatorRef allocator, const uint8_t *bytes, CFIndex length, CFAllocatorRef bytesDeallocator) { CFAssert1((0 == length || bytes != NULL), __kCFLogAssertion, "%s(): bytes pointer cannot be NULL if length is non-zero", __PRETTY_FUNCTION__); if (NULL == bytesDeallocator) bytesDeallocator = __CFGetDefaultAllocator(); return __CFDataInit(allocator, kCFImmutable, length, bytes, length, bytesDeallocator); }
CFDataRef CFDataCreate(CFAllocatorRef allocator, const uint8_t *bytes, CFIndex length) { return __CFDataInit(allocator, kCFImmutable, length, bytes, length, NULL); }