dynamic_buffer.h v0.2.2
Reference-counted byte buffer library for efficient I/O operations
Loading...
Searching...
No Matches
Functions
Buffer Modification <br>

Functions for modifying buffer contents and size. More...

Functions

DB_DEF db_buffer db_append (db_buffer buf, const void *data, size_t size)
 Create new buffer with data appended.
 

Detailed Description

Functions for modifying buffer contents and size.

Function Documentation

◆ db_append()

DB_DEF db_buffer db_append ( db_buffer  buf,
const void *  data,
size_t  size 
)

Create new buffer with data appended.

Parameters
bufSource buffer (must not be NULL)
dataData to append (can be NULL if size is 0)
sizeNumber of bytes to append
Returns
New buffer with appended data (asserts on allocation failure)
Note
Original buffer remains unchanged (immutable operation)
Example:
db_buffer buf1 = db_new_with_data("Hello", 5);
db_buffer buf2 = db_append(buf1, " World", 6);
// buf1 still contains "Hello"
// buf2 contains "Hello World"
db_release(&buf1);
db_release(&buf2);
char * db_buffer
Buffer handle - points directly to buffer data.
Definition dynamic_buffer.h:173
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 void db_release(db_buffer *buf_ptr)
Decrease reference count and potentially free buffer.
DB_DEF db_buffer db_append(db_buffer buf, const void *data, size_t size)
Create new buffer with data appended.