group
group__libshare__membuf
Dynamic memory buffer allocation utilities.
Dynamic Memory Buffer
typedef struct shbuf_t shbuf_t
int shbuf_cmp
(shbuf_t *buff, shbuf_t *cmp_buff)
Return Value
TRUE or FALSE whether buffers contain identical data.
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
void shbuf_catstr
(shbuf_t *buf, char *data)
Inserts a string into a memory pool.
shbuf_t
structshbuf__t
compound
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
void shbuf_memcpy
(shbuf_t *buf, void *data, size_t data_len)
size_t shbuf_size
(shbuf_t *buf)
The current size of the data segement stored in the memory buffer.
unsigned char* shbuf_data
(shbuf_t *buf)
void shbuf_clear
(shbuf_t *buf)
Clear the contents of a libshare memory buffer.
shbuf_t
structshbuf__t
compound
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.
void shbuf_truncate
(shbuf_t *buf, size_t len)
void shbuf_dealloc
(shbuf_t *buf)
void shbuf_free
(shbuf_t **buf_p)
Frees the resources utilizited by the memory buffer.
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.
shbuf_t* shbuf_file
(char *path)
Map a file into a memory buffer.
int shbuf_growmap
(shbuf_t *buf, size_t data_len)
shbuf_t* shbuf_map
(unsigned char *data, size_t data_len)
shbuf_t* ashbuf_map
(unsigned char *data, size_t data_len)
unsigned char* shbuf_unmap
(shbuf_t *buf)
size_t shbuf_pos
(shbuf_t *buff)
void shbuf_pos_set
(shbuf_t *buff, size_t pos)
void shbuf_pos_incr
(shbuf_t *buff, size_t pos)
size_t shbuf_idx
(shbuf_t *buf, unsigned char ch)
void shbuf_padd
(shbuf_t *buff, size_t len)