Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CoreFoundation/Collections.subproj/CFData.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,11 @@ CFTypeID CFDataGetTypeID(void) {
void _CFDataInit(CFMutableDataRef memory, CFOptionFlags variety, CFIndex capacity, const uint8_t *bytes, CFIndex length, Boolean noCopy) {
Boolean isMutable = ((variety & __kCFMutableMask) != 0);
Boolean isGrowable = ((variety & __kCFGrowableMask) != 0);
Boolean isDontDeallocate = ((variety & __kCFDontDeallocate) != 0);

__CFDataSetNumBytesUsed(memory, 0);
__CFDataSetLength(memory, 0);
__CFDataSetDontDeallocate(memory, true);
__CFDataSetDontDeallocate(memory, isDontDeallocate);

if (isMutable && isGrowable) {
__CFDataSetCapacity(memory, __CFDataRoundUpCapacity(1));
Expand Down
9 changes: 4 additions & 5 deletions Foundation/NSData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,10 @@ private final class _NSDataDeallocator {

private let __kCFMutable: CFOptionFlags = 0x01
private let __kCFGrowable: CFOptionFlags = 0x02
private let __kCFMutableVarietyMask: CFOptionFlags = 0x03
private let __kCFBytesInline: CFOptionFlags = 0x04
private let __kCFUseAllocator: CFOptionFlags = 0x08
private let __kCFDontDeallocate: CFOptionFlags = 0x10
private let __kCFAllocatesCollectable: CFOptionFlags = 0x20

private let __kCFBytesInline: CFOptionFlags = 2
private let __kCFUseAllocator: CFOptionFlags = 3
private let __kCFDontDeallocate: CFOptionFlags = 4

open class NSData : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
typealias CFType = CFData
Expand Down