Creates a stream that reads/writes to a dynamic vl_buffer.
██ ██ ██ █████ ███████ █████ ██████ ███ ██ █████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ███████ ███████ ███████ ██ ███ ██ ██ ██ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ███████ ██ ██ ███████ ██ ██ ██████ ██ ████ ██ ██ ====—: A Data Structure and Algorithms library for C11. :—====
Copyright 2026 Jesse Walker, released under the MIT license. Git Repository: https://github.com/walkerje/veritable_lasagna
Contract
- Ownership: The caller owns the returned
vl_stream pointer and is responsible for calling vlStreamDelete. If takeOwnership is VL_TRUE, the stream assumes ownership of the vl_buffer and will delete it (via vlBufferDelete) when the stream is destroyed.
- Lifetime: The stream is valid until its reference count reaches zero. The
vl_buffer must remain valid for the duration of the stream's life if takeOwnership is VL_FALSE.
- Thread Safety: Thread-safe (the stream has its own internal mutex).
- Nullability: Returns
NULL if buffer is NULL.
- Error Conditions: Returns
NULL on allocation failure.
- Undefined Behavior: Accessing the
vl_buffer directly while it is being managed by a stream from multiple threads without external synchronization.
- Memory Allocation Expectations: Allocates memory for the
vl_stream struct, an internal context struct, and synchronization primitives.
- Return-value Semantics: Returns a pointer to the new stream, or
NULL if failure.
- Parameters
-
| buffer | The buffer to use. |
| takeOwnership | If VL_TRUE, the stream will delete the buffer when closed. |
- Returns
- A new stream object.