From Binary Data Programming Guide
NSMutableData responds to dataWithBytesNoCopy:length:, but the bytes are copied anyway and the buffer is freed immediately.
It gives an error in accessing the buffer after NSData is created.(in memset in below code)
buffer is freed immediately.
The malloced buffer pointer and [data bytes] pointer are different.
NSMutableData
create copy of bytes.