Contents

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