withBytesNoCopy
Creates and initializes an instance of OSData that shares the provided data buffer.
Declaration
static OSData * withBytesNoCopy(
void *bytes,
unsigned intnumBytes);Parameters
- bytes:
The buffer of data to represent.
- numBytes:
The length of
bytes.
Return Value
A instance of OSData that shares the provided byte array, with a reference count of 1; NULL<coe> on failure.
Overview
An OSData object created with this function does not claim ownership of the data buffer, but shares it with the caller. When the caller determines that the OSData object has actually been freed, it can safely dispose of the data buffer. Conversely, if it frees the shared data buffer, it must not attempt to use the OSData object and should release it.
An OSData object created with shared external data cannot append bytes, but you can get the byte pointer and modify bytes within the shared buffer.
See Also
Miscellaneous
appendByteappendBytes(const OSData *)appendBytes(const void *, unsigned int)ensureCapacityfreegetBytesNoCopy()getBytesNoCopy(unsigned int, unsigned int)getCapacitygetCapacityIncrementgetLengthinitWithBytesinitWithBytesNoCopyinitWithCapacityinitWithData(const OSData *)initWithData(const OSData *, unsigned int, unsigned int)isEqualTo(const OSData *)isEqualTo(const OSMetaClassBase *)isEqualTo(const OSString *)isEqualTo(const void *, unsigned int)serializesetCapacityIncrementwithByteswithCapacitywithData(const OSData *)withData(const OSData *, unsigned int, unsigned int)