Veritable Lasagna
An Allocator & Data Structure Library for C.
Loading...
Searching...
No Matches
vl_stream_memory.h File Reference
#include <vl/vl_buffer.h>
#include <vl/vl_memory.h>
#include <vl/vl_stream.h>
+ Include dependency graph for vl_stream_memory.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

VL_API vl_streamvlStreamOpenMemory (const void *memory, vl_memsize_t size)
 Creates a read-only stream from a raw memory block.
 
VL_API vl_streamvlStreamOpenMemoryMutable (void *memory, vl_memsize_t size)
 Creates a writable stream from a fixed-size memory block. Writing past the end will fail.
 

Function Documentation

◆ vlStreamOpenMemory()

VL_API vl_stream * vlStreamOpenMemory ( const void *  memory,
vl_memsize_t  size 
)

Creates a read-only stream from a raw memory block.

Contract

  • Ownership: The caller owns the returned vl_stream pointer. The memory block is NOT owned by the stream.
  • Lifetime: The stream is valid until its reference count reaches zero. The underlying memory block must remain valid and unchanged for the entire lifetime of the stream.
  • Thread Safety: Thread-safe (internal mutex).
  • Nullability: Returns NULL if memory is NULL.
  • Error Conditions: Returns NULL on allocation failure.
  • Undefined Behavior: Modifying the underlying memory while the stream is active.
  • 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 read-only stream, or NULL.
Parameters
memoryPointer to the data.
sizeSize of the data in bytes.
Returns
A new stream object.

◆ vlStreamOpenMemoryMutable()

VL_API vl_stream * vlStreamOpenMemoryMutable ( void *  memory,
vl_memsize_t  size 
)

Creates a writable stream from a fixed-size memory block. Writing past the end will fail.

Contract

  • Ownership: The caller owns the returned vl_stream pointer and the underlying memory block.
  • Lifetime: The stream is valid until its reference count reaches zero. The underlying memory block must remain valid for the entire lifetime of the stream.
  • Thread Safety: Thread-safe (internal mutex).
  • Nullability: Returns NULL if memory is NULL.
  • Error Conditions: Returns NULL on allocation failure. Write operations will fail if they exceed the specified size.
  • Undefined Behavior: None.
  • 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 writable stream, or NULL.
Parameters
memoryPointer to the writable data.
sizeSize of the data in bytes.
Returns
A new stream object.