---
title: "CFWriteStreamCreateWithBuffer(_:_:_:)"
framework: corefoundation
role: symbol
role_heading: Function
path: "corefoundation/cfwritestreamcreatewithbuffer(_:_:_:)"
---

# CFWriteStreamCreateWithBuffer(_:_:_:)

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

## Declaration

```swift
func CFWriteStreamCreateWithBuffer(_ alloc: CFAllocator!, _ buffer: UnsafeMutablePointer<UInt8>!, _ bufferCapacity: CFIndex) -> CFWriteStream!
```

## 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

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

## Discussion

Discussion When buffer is filled after writing bufferCapacity bytes, the stream is exhausted and its status becomes CFStreamStatus.atEnd. You must open the stream, using CFWriteStreamOpen(_:), before writing to it.

## See Also

### Creating a Write Stream

- [CFWriteStreamCreateWithAllocatedBuffers(_:_:)](corefoundation/cfwritestreamcreatewithallocatedbuffers(_:_:).md)
- [CFWriteStreamCreateWithFile(_:_:)](corefoundation/cfwritestreamcreatewithfile(_:_:).md)
