libonion
|
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...
#include <types.h>
Public Member Functions | |
onion_block * | onion_block_new () |
Creates a new block. | |
void | onion_block_free (onion_block *bl) |
Removes the current block. | |
void | onion_block_clear (onion_block *b) |
Discards all data on this block, and set the size to 0. | |
void | onion_block_min_maxsize (onion_block *b, int minsize) |
Ensures the block has at least this reserved memory space. | |
const char * | onion_block_data (const onion_block *b) |
Returns the current data. | |
off_t | onion_block_size (const onion_block *b) |
Returns current block size. | |
void | onion_block_rewind (onion_block *b, off_t n) |
Reduces the size of the block. | |
int | onion_block_add_char (onion_block *bl, char c) |
Adds a character to the block. | |
int | onion_block_add_str (onion_block *b, const char *str) |
Adds a string to the block. | |
int | onion_block_add_data (onion_block *bl, const char *data, size_t l) |
Adds raw data to the block. | |
int | onion_block_add_block (onion_block *b, onion_block *toadd) |
Appends both blocks on the first. |
Data Fields | |
char * | data |
int | size |
int | maxsize |
Data type to store some raw data
Normally it will be used to store strings when the size is unknown beforehand, but it can contain any type of data.
Use with care as in most situations it might not be needed and more efficient alternatives may exist.
int onion_block_add_block | ( | onion_block * | b, |
onion_block * | toadd | ||
) |
Appends both blocks on the first.
References data, onion_block_add_data(), and size.
int onion_block_add_char | ( | onion_block * | bl, |
char | c | ||
) |
Adds a character to the block.
References data, maxsize, ONION_BLOCK_GROW_EXPONENTIAL_LIMIT, onion_low_realloc(), and size.
Referenced by onion_block_data(), onion_dict_t::onion_dict_to_json(), onion_json_quote_add(), and onion_json_unquote_add().
int onion_block_add_data | ( | onion_block * | bl, |
const char * | data, | ||
size_t | l | ||
) |
Adds raw data to the block.
References data, maxsize, ONION_BLOCK_GROW_MIN_BLOCK, onion_low_free(), onion_low_scalar_malloc(), and size.
Referenced by onion_block_add_block(), onion_block_add_str(), and onion_json_quote_add().
int onion_block_add_str | ( | onion_block * | b, |
const char * | str | ||
) |
Adds a string to the block.
References onion_block_add_data(), and size.
Referenced by onion_webdav_write_propfind().
char* onion_block_t::data |
int onion_block_t::maxsize |
Referenced by onion_block_add_char(), onion_block_add_data(), onion_block_data(), onion_block_min_maxsize(), and onion_block_new().
int onion_block_t::size |