<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/CFWriteStreamCreateWithAllocatedBuffers(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@F@CFWriteStreamCreateWithAllocatedBuffers"
  },
  "title" : "CFWriteStreamCreateWithAllocatedBuffers(_:_:)"
}
-->

# CFWriteStreamCreateWithAllocatedBuffers(_:_:)

Creates a writable stream for a growable block of memory.

```
func CFWriteStreamCreateWithAllocatedBuffers(_ alloc: CFAllocator!, _ bufferAllocator: CFAllocator!) -> CFWriteStream!
```

## Parameters

`alloc`

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

`bufferAllocator`

The allocator to use to allocate memory for the stream’s memory buffers. Pass `NULL` or kCFAllocatorDefault to use the current default allocator.

## Return Value

A new write stream. Ownership follows the [The Create Rule](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/Concepts/Ownership.html#//apple_ref/doc/uid/20001148-103029).

## Discussion

New buffers are allocated using `bufferAllocator` as bytes are written to the stream. At any point, you can recover the bytes thus far written by asking for the property kCFStreamPropertyDataWritten with [`CFWriteStreamCopyProperty(_:_:)`](/documentation/CoreFoundation/CFWriteStreamCopyProperty(_:_:)).

You must open the stream, using [`CFWriteStreamOpen(_:)`](/documentation/CoreFoundation/CFWriteStreamOpen(_:)), before writing to it.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)