Regional allocator. More...
Data Structures | |
struct | regional |
the regional* is the first block*. More... | |
Functions | |
struct regional * | regional_create (void) |
Create a new regional. More... | |
struct regional * | regional_create_custom (size_t size) |
Create a new region, with custom settings. More... | |
struct regional * | regional_create_nochunk (size_t size) |
Create a new region, with custom settings, that will allocate everything outside the region chunk. 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... | |
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. Based on region-allocator from NSD, but rewritten to be light.
Different from (nsd) region-allocator.h o does not have recycle bin o does not collect stats; just enough to answer get_mem() in use. o does not keep cleanup list o does not have function pointers to setup o allocs the regional struct inside the first block. o can take a block to create regional from. o blocks and large allocations are kept on singly linked lists.
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(), edns_ede_answer_encode_test(), edns_strings_create(), nsec3_hash_test(), perf_encode(), perftestpkt(), priv_create(), process_answer_detail(), respip_set_create(), specific_cases(), tcl_list_create(), testpkt(), verifytest_file(), zonemd_generate_test(), zonemd_offline_verify(), and zonemd_verify_test().
struct regional* regional_create_custom | ( | size_t | size | ) |
Create a new region, with custom settings.
size | length of first block. |
References regional_create_custom_large_object(), and REGIONAL_LARGE_OBJECT_SIZE.
Referenced by alloc_reg_obtain(), burden_test(), libworker_setup(), prealloc_blocks(), regional_create(), rpz_create(), and specific_cases().
struct regional* regional_create_nochunk | ( | size_t | size | ) |
Create a new region, with custom settings, that will allocate everything outside the region chunk.
size | length of first block. |
References regional_create_custom_large_object().
Referenced by local_zone_create().
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_interface_init(), acl_list_apply_cfg(), alloc_reg_release(), auth_zone_verify_zonemd(), auth_zone_zonemd_check_hash(), autr_probe_timer(), burden_test(), check_az_q_ans(), delete_cname_override(), donotq_apply_cfg(), dstest_entry(), dump_msg_lruhash(), edns_strings_apply_cfg(), handle_newq(), iter_indicates_dnssec(), libworker_attach_mesh(), libworker_fg(), load_msg(), load_rrset(), mesh_run(), priv_apply_cfg(), regional_destroy(), reply_equal(), tcl_list_apply_cfg(), verifytest_entry(), zonemd_simple_rrset(), and zonemd_simple_rrsig().
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(), edns_strings_delete(), libworker_delete_env(), local_zone_delete(), priv_delete(), respip_set_delete(), specific_cases(), worker_delete(), zonemd_generate_test(), and zonemd_offline_verify().
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::large_object_size, regional::next, REGIONAL_CHUNK_SIZE, and regional::total_large.
Referenced by burden_test(), compress_tree_newnode(), construct_reply_info_base(), createResponse(), delegpt_add_addr(), delegpt_add_ns(), delegpt_create(), dns64_adjust_a(), dns64_adjust_ptr(), dns64_inform_super(), dns64_operate(), dns_alloc_msg(), dns_copy_msg(), dns_msg_create(), donotq_insert(), edns_opt_list_append(), edns_opt_list_append_ede(), gen_dns_msg(), generate_sub_request(), 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_cache_table_init(), nsec3_calc_hash(), nsec3_ce_wildcard(), nsec3_hash_name(), outnet_serviced_query(), packed_rrset_copy_region(), parse_copy_decompress_rrset(), parse_create_qinfo(), parse_reply_in_temp_region(), read_addrs(), read_names(), regional_alloc_zero(), reply_info_alloc_rrset_keys(), reply_info_copy(), reply_info_parse(), respip_copy_rrset(), rrset_array_unlock_touch(), rrset_canonical(), rrset_canonical_equal(), rrset_canonicalize_to_buffer(), sock_list_insert(), synth_cname_rrset(), val_new(), worker_send_query(), and zonemd_simple_rrsig_allocs().
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. |
Referenced by auth_zone_delegpt(), copy_msg(), delegpt_add_ns(), delegpt_set_name(), dns_copy_msg(), dns_msg_create(), edns_opt_copy_filter_region(), 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_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(), read_names(), regional_strdup(), repinfo_copy_rrsets(), reply_equal(), respip_copy_rrset(), respip_operate(), and serviced_create().
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(), auth_zone_delegpt(), cfg_region_strlist_insert(), dns_msg_create(), get_rrset_trust(), iter_store_parentside_neg(), load_rrset(), local_data_find_tag_datas(), lz_enter_override(), lz_find_create_node(), mesh_serve_expired_init(), mesh_state_add_reply(), msg_create(), msg_grow_array(), new_cname_override(), new_local_rrset(), new_rrset(), respip_copy_rrset(), respip_operate(), respip_sockaddr_find_or_create(), rpz_add_soa(), rpz_apply_cname_override_action(), and tcl_list_insert().
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 delegpt_add_addr(), delegpt_add_ns(), dns_msg_deepcopy_region(), errinf_to_str_bogus(), errinf_to_str_misc(), errinf_to_str_servfail(), key_entry_copy_toregion(), key_entry_create_bad(), key_entry_create_null(), key_entry_create_rrset(), serviced_create(), and tomsg().