dynamic_buffer.h v0.2.2
Reference-counted byte buffer library for efficient I/O operations
|
Functions for creating and destroying buffers. More...
Functions | |
DB_DEF db_buffer | db_new (size_t capacity) |
Create a new empty buffer with specified capacity. | |
DB_DEF db_buffer | db_new_with_data (const void *data, size_t size) |
Create a new buffer initialized with data (copies the data) | |
DB_DEF db_buffer | db_new_from_owned_data (void *data, size_t size, size_t capacity) |
Create a new buffer by copying existing data. | |
DB_DEF db_buffer | db_retain (db_buffer buf) |
Increase reference count (share ownership) | |
DB_DEF void | db_release (db_buffer *buf_ptr) |
Decrease reference count and potentially free buffer. | |
Functions for creating and destroying buffers.
Create a new empty buffer with specified capacity.
capacity | Initial capacity in bytes (0 for minimal allocation) |
Create a new buffer by copying existing data.
data | Pointer to data to copy |
size | Size of the data in bytes |
capacity | Total allocated capacity (must be >= size) |
Create a new buffer initialized with data (copies the data)
data | Pointer to source data (can be NULL if size is 0) |
size | Number of bytes to copy |
Decrease reference count and potentially free buffer.
buf_ptr | Pointer to buffer variable (will be set to NULL) |