This file contains the definition of sldns_buffer, and functions to manipulate those. More...
Functions | |
sldns_buffer * | sldns_buffer_new (size_t capacity) |
creates a new buffer with the specified capacity. More... | |
void | sldns_buffer_new_frm_data (sldns_buffer *buffer, void *data, size_t size) |
creates a buffer with the specified data. More... | |
void | sldns_buffer_init_frm_data (sldns_buffer *buffer, void *data, size_t size) |
Setup a buffer with the data pointed to. More... | |
int | sldns_buffer_set_capacity (sldns_buffer *buffer, size_t capacity) |
changes the buffer's capacity. More... | |
int | sldns_buffer_reserve (sldns_buffer *buffer, size_t amount) |
ensures BUFFER can contain at least AMOUNT more bytes. More... | |
int | sldns_buffer_printf (sldns_buffer *buffer, const char *format,...) |
void | sldns_buffer_free (sldns_buffer *buffer) |
frees the buffer. More... | |
void | sldns_buffer_copy (sldns_buffer *result, sldns_buffer *from) |
Copy contents of the from buffer to the result buffer and then flips the result buffer. More... | |
This file contains the definition of sldns_buffer, and functions to manipulate those.
sldns_buffer* sldns_buffer_new | ( | size_t | capacity | ) |
creates a new buffer with the specified capacity.
[in] | capacity | the size (in bytes) to allocate for the buffer |
References sldns_buffer::_capacity, sldns_buffer::_data, sldns_buffer::_fixed, sldns_buffer::_limit, sldns_buffer::_position, and sldns_buffer::_status_err.
Referenced by anchors_apply_cfg(), anchors_test(), answer_callback_from_entry(), check_mod(), comm_point_create_http_out(), comm_point_create_local(), comm_point_create_tcp_handler(), comm_point_create_tcp_out(), comm_point_tcp_handle_callback(), dname_test(), dstest_file(), hex_buffer2wire(), libworker_setup(), listen_create(), main(), mesh_create(), msgparse_test(), nsec3_hash_test(), outside_network_create(), pending_tcp_query(), pending_udp_query(), process_answer_detail(), send_em(), service(), verifytest_file(), zonemd_generate_test(), and zonemd_offline_verify().
void sldns_buffer_new_frm_data | ( | sldns_buffer * | buffer, |
void * | data, | ||
size_t | size | ||
) |
creates a buffer with the specified data.
The data IS copied and MEMORY allocations are done. The buffer is not fixed and can be resized using buffer_reserve().
[in] | buffer | pointer to the buffer to put the data in |
[in] | data | the data to encapsulate in the buffer |
[in] | size | the size of the data |
References sldns_buffer::_capacity, sldns_buffer::_data, sldns_buffer::_fixed, sldns_buffer::_limit, sldns_buffer::_position, and sldns_buffer::_status_err.
Referenced by hex_buffer2wire().
void sldns_buffer_init_frm_data | ( | sldns_buffer * | buffer, |
void * | data, | ||
size_t | size | ||
) |
Setup a buffer with the data pointed to.
No data copied, no memory allocs. The buffer is fixed.
[in] | buffer | pointer to the buffer to put the data in |
[in] | data | the data to encapsulate in the buffer |
[in] | size | the size of the data |
References sldns_buffer::_capacity, sldns_buffer::_data, sldns_buffer::_fixed, and sldns_buffer::_limit.
Referenced by decompress_rr_into_buffer().
int sldns_buffer_set_capacity | ( | sldns_buffer * | buffer, |
size_t | capacity | ||
) |
changes the buffer's capacity.
The data is reallocated so any pointers to the data may become invalid. The buffer's limit is set to the buffer's new capacity.
[in] | buffer | the buffer |
[in] | capacity | the capacity to use |
int sldns_buffer_reserve | ( | sldns_buffer * | buffer, |
size_t | amount | ||
) |
ensures BUFFER can contain at least AMOUNT more bytes.
The buffer's capacity is increased if necessary using buffer_set_capacity().
The buffer's limit is always set to the (possibly increased) capacity.
[in] | buffer | the buffer |
[in] | amount | amount to use |
void sldns_buffer_free | ( | sldns_buffer * | buffer | ) |
frees the buffer.
[in] | *buffer | the buffer to be freed |
References sldns_buffer::_data, and sldns_buffer::_fixed.
Referenced by anchors_apply_cfg(), anchors_test(), comm_point_create_http_out(), comm_point_create_tcp_handler(), comm_point_create_tcp_out(), comm_point_delete(), comm_point_drop_reply(), delete_fake_pending(), delete_replay_answer(), delete_replylist(), dname_test(), libworker_delete_env(), libworker_setup(), listen_delete(), mesh_delete(), outnet_serviced_query_stop(), outside_network_delete(), send_em(), worker_delete(), zonemd_generate_test(), and zonemd_offline_verify().
void sldns_buffer_copy | ( | sldns_buffer * | result, |
sldns_buffer * | from | ||
) |
Copy contents of the from buffer to the result buffer and then flips the result buffer.
Data will be silently truncated if the result buffer is too small.
[out] | *result | resulting buffer which is copied to. |
[in] | *from | what to copy to result. |
References sldns_buffer_begin(), sldns_buffer_capacity(), sldns_buffer_clear(), sldns_buffer_flip(), sldns_buffer_limit(), and sldns_buffer_write().
Referenced by entry_to_buf(), mesh_make_new_space(), and reply_and_prefetch().