group
group__libshare__membuf
Dynamic memory buffer allocation utilities.

Dynamic Memory Buffer

typedef
typedef struct shbuf_t shbuf_t
function
int shbuf_cmp
(shbuf_t *buff, shbuf_t *cmp_buff)
Return Value
TRUE or FALSE whether buffers contain identical data.
function
shbuf_t* shbuf_init
(void)
Initialize a memory buffer for use.
Note
A memory buffer handles automatic allocation of memory.
shbuf_t structshbuf__t compound
function
void shbuf_catstr
(shbuf_t *buf, char *data)
Inserts a string into a memory pool.
shbuf_t structshbuf__t compound
function
void shbuf_cat
(shbuf_t *buf, void *data, size_t data_len)
Inserts a binary data segment into a memory pool.
shbuf_t structshbuf__t compound
function
void shbuf_memcpy
(shbuf_t *buf, void *data, size_t data_len)
function
size_t shbuf_size
(shbuf_t *buf)
The current size of the data segement stored in the memory buffer.
function
unsigned char* shbuf_data
(shbuf_t *buf)
function
void shbuf_clear
(shbuf_t *buf)
Clear the contents of a libshare memory buffer.
shbuf_t structshbuf__t compound
function
void shbuf_trim
(shbuf_t *buf, size_t len)
Reduce the data size of a memory buffer.
Param
buf
The memory buffer.
len
The size of bytes to reduce by.
Note
This removes data from the beginning of the data segment.
function
void shbuf_truncate
(shbuf_t *buf, size_t len)
function
void shbuf_dealloc
(shbuf_t *buf)
function
void shbuf_free
(shbuf_t **buf_p)
Frees the resources utilizited by the memory buffer.
function
int shbuf_grow
(shbuf_t *buf, size_t data_len)
Grow the memory buffer to atleast the size specified.
Param
buf
The memory buffer. shbuf_t structshbuf__t compound
data_len
The minimum byte size the memory buffer should be allocated.
function
shbuf_t* shbuf_file
(char *path)
Map a file into a memory buffer.
function
int shbuf_growmap
(shbuf_t *buf, size_t data_len)
function
shbuf_t* shbuf_map
(unsigned char *data, size_t data_len)
function
shbuf_t* ashbuf_map
(unsigned char *data, size_t data_len)
function
unsigned char* shbuf_unmap
(shbuf_t *buf)
function
size_t shbuf_pos
(shbuf_t *buff)
function
void shbuf_pos_set
(shbuf_t *buff, size_t pos)
function
void shbuf_pos_incr
(shbuf_t *buff, size_t pos)
function
size_t shbuf_idx
(shbuf_t *buf, unsigned char ch)
function
void shbuf_padd
(shbuf_t *buff, size_t len)
define
SHBUF_PREALLOC
(1 << 0)
define
SHBUF_FMAP
(1 << 1)