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
2 changes: 2 additions & 0 deletions Source/NSData.m
Original file line number Diff line number Diff line change
Expand Up @@ -3548,6 +3548,8 @@ - (instancetype) initWithBytesNoCopy: (void*)buf
}

GSClassSwizzle(self, dataBlock);
bytes = buf;
length = len;
ASSIGN(deallocator, (id)deallocBlock);
return self;
}
Expand Down
4 changes: 4 additions & 0 deletions Tests/base/NSData/general.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ int main()
deallocator: ^(void* bytes, NSUInteger length) {
called++;
}];
PASS([immutable length] == 4, "Length set");
PASS([immutable bytes] == stackBuf, "Bytes set");
PASS_RUNS([immutable release]; immutable = nil;,
"No free() error with custom deallocator");
PASS(called == 1, "Deallocator block called");
Expand All @@ -102,6 +104,8 @@ int main()
called++;
}
];
PASS([mutable length] == 4, "Length set");
PASS([mutable bytes] == buf, "Bytes set");
PASS_RUNS([mutable release]; mutable = nil;,
"No free() error with custom deallocator on mutable data");
PASS(called == 2, "Deallocator block called on -dealloc of mutable data");
Expand Down