libonion
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Functions
Block. Variable size bytes blocks. Used for some internal string representation.

Data Structures

struct  onion_block_t
 Data type to store some raw dataNormally it will be used to store strings when the size is unknown beforehand, but it can contain any type of data. More...

Functions

onion_blockonion_block_t::onion_block_new ()
 Creates a new block.
void onion_block_t::onion_block_free (onion_block *bl)
 Removes the current block.
void onion_block_t::onion_block_clear (onion_block *b)
 Discards all data on this block, and set the size to 0.
void onion_block_t::onion_block_min_maxsize (onion_block *b, int minsize)
 Ensures the block has at least this reserved memory space.
const char * onion_block_t::onion_block_data (const onion_block *b)
 Returns the current data.
off_t onion_block_t::onion_block_size (const onion_block *b)
 Returns current block size.
void onion_block_t::onion_block_rewind (onion_block *b, off_t n)
 Reduces the size of the block.

Detailed Description

Function Documentation

void onion_block_clear ( onion_block b)

Discards all data on this block, and set the size to 0.

This is usefull to reuse existing blocks

References onion_block_t::size.

const char * onion_block_data ( const onion_block b)
void onion_block_free ( onion_block bl)
void onion_block_min_maxsize ( onion_block b,
int  minsize 
)

Ensures the block has at least this reserved memory space.

This is usefull for some speedups, and prevent sucessive mallocs if you know beforehand the size.

References onion_block_t::data, onion_block_t::maxsize, and onion_low_realloc().

Referenced by onion_json_quote_add().

onion_block * onion_block_new ( )
void onion_block_rewind ( onion_block b,
off_t  n 
)

Reduces the size of the block.

References onion_block_t::size.

Referenced by onion_dict_t::onion_dict_to_json().

off_t onion_block_size ( const onion_block b)