unbound
0.1
|
Regional allocator. More...
Macros | |
#define | ALIGN_UP(x, s) (((x) + s - 1) & (~(s - 1))) |
increase size until it fits alignment of s bytes | |
#define | ALIGNMENT (sizeof(uint64_t)) |
what size to align on; make sure a char* fits in it. More... | |
#define | REGIONAL_CHUNK_SIZE 8192 |
Default reasonable size for chunks. | |
#define | REGIONAL_LARGE_OBJECT_SIZE 2048 |
Default size for large objects - allocated outside of chunks. More... | |
Functions | |
struct regional * | regional_create (void) |
Create a new regional. More... | |
static void | regional_init (struct regional *r) |
init regional struct with first block | |
struct regional * | regional_create_custom (size_t size) |
Create a new region, with custom settings. More... | |
void | regional_free_all (struct regional *r) |
Free all memory associated with regional. More... | |
void | regional_destroy (struct regional *r) |
Destroy regional. More... | |
void * | regional_alloc (struct regional *r, size_t size) |
Allocate size bytes of memory inside regional. More... | |
void * | regional_alloc_init (struct regional *r, const void *init, size_t size) |
Allocate size bytes of memory inside regional and copy INIT into it. More... | |
void * | regional_alloc_zero (struct regional *r, size_t size) |
Allocate size bytes of memory inside regional that are initialized to 0. More... | |
char * | regional_strdup (struct regional *r, const char *string) |
Duplicate string and allocate the result in regional. More... | |
static size_t | count_chunks (struct regional *r) |
reasonably slow, but stats and get_mem are not supposed to be fast count the number of chunks in use | |
static size_t | count_large (struct regional *r) |
also reasonably slow, counts the number of large objects | |
void | regional_log_stats (struct regional *r) |
Debug print regional statistics to log. | |
size_t | regional_get_mem (struct regional *r) |
get total memory size in use by region | |
Regional allocator.
Allocates small portions of of larger chunks.
#define ALIGNMENT (sizeof(uint64_t)) |
what size to align on; make sure a char* fits in it.
Referenced by regional_alloc(), regional_init(), and regional_log_stats().
#define REGIONAL_LARGE_OBJECT_SIZE 2048 |
Default size for large objects - allocated outside of chunks.
Referenced by regional_alloc(), and regional_log_stats().
struct regional* regional_create | ( | void | ) |
Create a new regional.
References REGIONAL_CHUNK_SIZE, and regional_create_custom().
Referenced by acl_list_create(), check_az_q_ans(), check_mod(), donotq_create(), dstest_file(), log_dns_msg(), nsec3_hash_test(), perf_encode(), perftestpkt(), priv_create(), process_answer_detail(), respip_set_create(), specific_cases(), testpkt(), and verifytest_file().
struct regional* regional_create_custom | ( | size_t | size | ) |
Create a new region, with custom settings.
size | length of first block. |
References regional::first_size, log_assert, and regional_init().
Referenced by alloc_reg_obtain(), burden_test(), libworker_setup(), local_zone_create(), prealloc_blocks(), regional_create(), and specific_cases().
void regional_free_all | ( | struct regional * | r | ) |
Free all memory associated with regional.
Only keeps the first block with the regional inside it.
r | the region. |
References regional::large_list, regional::next, and regional_init().
Referenced by acl_list_apply_cfg(), alloc_reg_release(), autr_probe_timer(), burden_test(), check_az_q_ans(), corner_cases(), donotq_apply_cfg(), dstest_entry(), dump_msg_lruhash(), handle_newq(), iter_indicates_dnssec(), libworker_attach_mesh(), libworker_fg(), load_msg(), load_rrset(), mesh_run(), priv_apply_cfg(), regional_destroy(), reply_equal(), val_verify_rrset(), and verifytest_entry().
void regional_destroy | ( | struct regional * | r | ) |
Destroy regional.
All memory associated with regional is freed as if regional_free_all was called, as well as destroying the regional struct.
r | to delete. |
References regional_free_all().
Referenced by acl_list_delete(), alloc_reg_release(), burden_test(), check_az_q_ans(), donotq_delete(), libworker_delete_env(), local_zone_delete(), log_dns_msg(), priv_delete(), respip_set_delete(), and specific_cases().
void* regional_alloc | ( | struct regional * | r, |
size_t | size | ||
) |
Allocate size bytes of memory inside regional.
The memory is deallocated when region_free_all is called for this region.
r | the region. |
size | number of bytes. |
References ALIGN_UP, ALIGNMENT, regional::available, regional::data, regional::large_list, regional::next, REGIONAL_CHUNK_SIZE, REGIONAL_LARGE_OBJECT_SIZE, and regional::total_large.
Referenced by burden_test(), compress_tree_newnode(), construct_reply_info_base(), copy_rrset(), corner_cases(), createResponse(), delegpt_add_addr(), delegpt_add_ns(), delegpt_create(), dns64_adjust_a(), dns64_adjust_ptr(), dns_alloc_msg(), dns_copy_msg(), dns_msg_create(), donotq_insert(), edns_opt_append(), edns_opt_list_append(), errinf(), gen_dns_msg(), generate_sub_request(), handle_ipv6_ptr(), iter_add_prepend_answer(), iter_add_prepend_auth(), iter_new(), iter_prepend(), iter_store_parentside_neg(), key_entry_get_rrset(), key_entry_setup(), libworker_send_query(), mesh_state_add_cb(), mesh_state_add_reply(), mesh_state_attachment(), mesh_state_create(), moveover_rrsigs(), msg_create(), new_rrset(), nsec3_calc_hash(), nsec3_ce_wildcard(), nsec3_hash_name(), packed_rrset_copy_region(), parse_copy_decompress_rrset(), parse_create_qinfo(), parse_create_rrset(), parse_reply(), read_addrs(), read_names(), regional_alloc_init(), regional_alloc_zero(), reply_info_alloc_rrset_keys(), reply_info_parse(), rrset_array_unlock_touch(), rrset_canonical(), rrset_canonical_equal(), sock_list_insert(), synth_cname_rrset(), val_dlv_init(), val_new(), and worker_send_query().
void* regional_alloc_init | ( | struct regional * | r, |
const void * | init, | ||
size_t | size | ||
) |
Allocate size bytes of memory inside regional and copy INIT into it.
The memory is deallocated when region_free_all is called for this region.
r | the region. |
init | to copy. |
size | number of bytes. |
References regional_alloc().
Referenced by acl_list_tags_cfg(), copy_msg(), copy_rrset(), corner_cases(), delegpt_add_ns(), delegpt_set_name(), dns_copy_msg(), dns_msg_create(), edns_opt_append(), edns_opt_copy_region(), edns_opt_list_append(), gen_dns_msg(), iter_store_parentside_neg(), key_entry_copy_toregion(), key_entry_create_rrset(), key_entry_get_rrset(), key_entry_setup(), load_qinfo(), load_rr(), local_data_find_tag_datas(), lz_find_create_node(), mesh_state_add_reply(), mesh_state_create(), msg_create(), nsec3_calc_b32(), packed_rrset_copy_region(), probe_anchor(), process_ds_response(), processDLVLookup(), read_names(), regional_strdup(), repinfo_copy_rrsets(), and respip_operate().
void* regional_alloc_zero | ( | struct regional * | r, |
size_t | size | ||
) |
Allocate size bytes of memory inside regional that are initialized to 0.
The memory is deallocated when region_free_all is called for this region.
r | the region. |
size | number of bytes. |
References regional_alloc().
Referenced by acl_list_insert(), acl_list_tag_action_cfg(), acl_list_tag_data_cfg(), cfg_region_strlist_insert(), corner_cases(), dns_msg_create(), iter_store_parentside_neg(), load_msg(), load_rrset(), local_data_find_tag_datas(), lz_enter_override(), lz_find_create_node(), mesh_state_add_reply(), msg_create(), msg_grow_array(), new_local_rrset(), new_rrset(), respip_find_or_create(), and respip_operate().
char* regional_strdup | ( | struct regional * | r, |
const char * | string | ||
) |
Duplicate string and allocate the result in regional.
r | the region. |
string | null terminated string. |
References regional_alloc_init().
Referenced by acl_list_tag_data_cfg(), algo_needs_reason(), corner_cases(), errinf(), key_entry_copy_toregion(), and key_entry_create_rrset().