Function

CFReadStreamCreateWithBytesNoCopy

Creates a readable stream for a block of memory.

Declaration

CFReadStreamRef CFReadStreamCreateWithBytesNoCopy(CFAllocatorRef alloc, const UInt8 *bytes, CFIndex length, CFAllocatorRef bytesDeallocator);

Parameters

alloc

The allocator to use to allocate memory for the new object. Pass NULL or kCFAllocatorDefault to use the current default allocator.

bytes

The memory buffer to read. This memory must exist for the lifetime of the new stream.

length

The size of bytes.

bytesDeallocator

The allocator to use to deallocate bytes when the stream is deallocated. Pass kCFAllocatorNull to prevent the stream from deallocating bytes.

Return Value

The new read stream, or NULL on failure. Ownership follows the The Create Rule.

Discussion

You must open the stream, using CFReadStreamOpen, before reading from it.

See Also

Creating a Read Stream

CFReadStreamCreateWithFile

Creates a readable stream for a file.