Function

CFWriteStreamCreateWithBuffer

Creates a writable stream for a fixed-size block of memory.

Declaration

CFWriteStreamRef CFWriteStreamCreateWithBuffer(CFAllocatorRef alloc, UInt8 *buffer, CFIndex bufferCapacity);

Parameters

alloc

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

buffer

The memory buffer into which to write data. This buffer must exist for the lifetime of the stream.

bufferCapacity

The size of buffer and the maximum number of bytes that can be written.

Return Value

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

Discussion

When buffer is filled after writing bufferCapacity bytes, the stream is exhausted and its status becomes kCFStreamStatusAtEnd.

You must open the stream, using CFWriteStreamOpen, before writing to it.

See Also

Creating a Write Stream

CFWriteStreamCreateWithAllocatedBuffers

Creates a writable stream for a growable block of memory.

CFWriteStreamCreateWithFile

Creates a writable stream for a file.