Tor 0.4.9.8
Loading...
Searching...
No Matches
malloc.h File Reference

Headers for util_malloc.c. More...

#include <assert.h>
#include <stddef.h>
#include <stdlib.h>
#include "lib/cc/compat_compiler.h"

Go to the source code of this file.

Macros

#define tor_free(p)
 
#define tor_malloc(size)
 
#define tor_malloc_zero(size)
 
#define tor_calloc(nmemb, size)
 
#define tor_realloc(ptr, size)
 
#define tor_reallocarray(ptr, sz1, sz2)
 
#define tor_strdup(s)
 
#define tor_strndup(s, n)
 
#define tor_memdup(s, n)
 
#define tor_memdup_nulterm(s, n)
 
#define raw_malloc   malloc
 
#define raw_realloc   realloc
 
#define raw_free   free
 
#define raw_strdup   strdup
 
#define FREE_AND_NULL(typename, freefn, var)
 

Functions

void * tor_malloc_ (size_t size) ATTR_MALLOC
 
void * tor_malloc_zero_ (size_t size) ATTR_MALLOC
 
void * tor_calloc_ (size_t nmemb, size_t size) ATTR_MALLOC
 
void * tor_realloc_ (void *ptr, size_t size)
 
void * tor_reallocarray_ (void *ptr, size_t size1, size_t size2)
 
char * tor_strdup_ (const char *s) ATTR_MALLOC
 
char * tor_strndup_ (const char *s, size_t n) ATTR_MALLOC
 
void * tor_memdup_ (const void *mem, size_t len) ATTR_MALLOC
 
void * tor_memdup_nulterm_ (const void *mem, size_t len) ATTR_MALLOC
 
void tor_free_ (void *mem)
 

Detailed Description

Headers for util_malloc.c.

Definition in file malloc.h.

Macro Definition Documentation

◆ FREE_AND_NULL

#define FREE_AND_NULL ( typename,
freefn,
var )
Value:
do { \
/* only evaluate (var) once. */ \
typename **tmp__free__ptr ## freefn = &(var); \
freefn(*tmp__free__ptr ## freefn); \
(*tmp__free__ptr ## freefn) = NULL; \
} while (0)

Definition at line 84 of file malloc.h.

◆ raw_free

#define raw_free   free

Definition at line 78 of file malloc.h.

◆ raw_malloc

#define raw_malloc   malloc

Definition at line 76 of file malloc.h.

◆ raw_realloc

#define raw_realloc   realloc

Definition at line 77 of file malloc.h.

◆ raw_strdup

#define raw_strdup   strdup

Definition at line 79 of file malloc.h.

◆ tor_calloc

#define tor_calloc ( nmemb,
size )
Value:
tor_calloc_(nmemb, size)
void * tor_calloc_(size_t nmemb, size_t size) ATTR_MALLOC
Definition malloc.c:107

Definition at line 64 of file malloc.h.

◆ tor_free

#define tor_free ( p)
Value:
STMT_BEGIN \
raw_free(p); \
(p)=NULL; \
STMT_END

Release memory allocated by tor_malloc, tor_realloc, tor_strdup, etc. Unlike the free() function, the tor_free() macro sets the pointer value to NULL after freeing it.

This is a macro. If you need a function pointer to release memory from tor_malloc(), use tor_free_().

Note that this macro takes the address of the pointer it is going to free and clear. If that pointer is stored with a nonstandard alignment (eg because of a "packed" pragma) it is not correct to use tor_free().

Definition at line 56 of file malloc.h.

Referenced by accounting_parse_options(), add_authmethods(), add_default_log(), add_onion_helper_keyarg(), add_rsa_fingerprint_to_dir(), addr_policy_free_(), address_ttl_free_(), addressmap_clear_excluded_trackexithosts(), addressmap_ent_free_(), addressmap_register(), addressmap_register_virtual_address(), addressmap_rewrite(), addressmap_rewrite_reverse(), addressmap_virtaddress_ent_free_(), addressmap_virtaddress_remove(), alloc_getcwd(), alloc_http_authenticator(), append_cell_stats_by_command(), assign_onionskin_to_cpuworker(), authority_cert_free_(), authority_cert_parse_from_string(), authority_certs_fetch_missing(), base32_decode(), begin_cell_parse(), bitarray_free_(), bloomfilt_free_(), bridge_add_from_config(), bridge_free_(), bridge_line_free_(), bridge_resolve_conflicts(), bridgeauth_dump_bridge_status_to_file(), bto_chan_clear_map(), bto_delete(), bto_gid_clear_map(), buf_add_vprintf(), buf_free_(), buf_http_find_content_length(), build_encrypted(), build_kdf_key(), build_service_descriptor(), bw_array_free_(), bwhist_update_bwhist_state_section(), cache_client_desc_free_(), cache_client_intro_state_add(), cache_client_intro_state_free_(), cache_dir_desc_free_(), cache_intro_state_free_(), cached_dir_decref(), calc_changes(), can_service_launch_intro_circuit(), cdm_diff_free_(), cert_list_free_(), cfx_del_leg(), cgo_crypt_free_(), cgo_uiv_update(), channel_do_open_actions(), channel_dump_statistics(), channel_force_xfree(), channel_free_(), channel_listener_force_xfree(), channel_listener_free_(), channel_mark_circid_usable(), channel_remove_from_digest_map(), channel_tls_connect(), channel_tls_describe_transport_method(), channel_tls_handle_incoming(), channel_tls_process_certs_cell(), check_descriptor_ipaddress_changed(), check_family_certs(), check_or_create_data_subdir(), check_private_dir(), check_signature_token(), check_tap_onion_key_crosscert(), choose_good_exit_server_general(), circpad_circuit_machineinfo_free_idx(), circpad_machine_setup_tokens(), circpad_machines_free(), circuit_all_predicted_ports_handled(), circuit_build_times_free_timeouts(), circuit_build_times_get_xm(), circuit_build_times_new_consensus_params(), circuit_build_times_parse_state(), circuit_build_times_update_state(), circuit_clear_isolation(), circuit_clear_testing_cell_stats(), circuit_describe_status_for_controller(), circuit_discard_optional_exit_enclaves(), circuit_free_(), circuit_free_all(), circuit_get_open_circ_or_launch(), circuit_guard_state_free_(), circuit_list_path_impl(), circuit_log_ancient_one_hop_circuits(), circuit_log_path(), circuit_n_chan_done(), circuit_remove_handled_ports(), circuitmux_detach_all_circuits(), circuitmux_detach_circuit(), circuitmux_free_(), clear_cached_dir(), clear_geoip_db(), clear_trackexithost_mappings(), clear_waitpid_callback(), client_check_address_changed(), client_circ_negotiation_message(), client_dns_set_addressmap_impl(), client_dns_set_reverse_addressmap(), client_likes_consensus(), clock_skew_warning(), collect_period_statistics(), command_process_create_cell(), compute_consensus_package_lines(), compute_nth_protocol_set(), compute_routerstatus_consensus(), config_assign(), config_assign_line(), config_dump(), config_free_(), config_free_all(), config_free_lines_(), config_generic_service(), config_get_assigned_option(), config_get_lines_aux(), config_load_geoip_file_(), config_mgr_free_(), config_parse_units(), config_register_addressmaps(), config_reset(), config_service(), config_suite_free_(), configure_nameservers(), conflux_process_link(), conflux_process_linked(), conflux_relay_msg_free_(), congestion_control_build_ext_response(), congestion_control_free_(), conn_stats_free_all(), conn_stats_save(), connection_ap_handle_onion(), connection_ap_handshake_attach_circuit(), connection_ap_handshake_rewrite_and_attach(), connection_ap_handshake_socks_resolved(), connection_ap_process_end_not_open(), connection_ap_process_http_connect(), connection_control_process_inbuf(), connection_dir_bridge_routerdesc_failed(), connection_dir_client_reached_eof(), connection_dir_download_cert_failed(), connection_dns_remove(), connection_exit_begin_conn(), connection_ext_or_auth_handle_client_nonce(), connection_ext_or_handle_cmd_transport(), connection_ext_or_handle_cmd_useraddr(), connection_free_all(), connection_free_minimal(), connection_haproxy_proxy_connect(), connection_https_proxy_connect(), connection_listener_new_for_port(), connection_or_check_canonicity(), connection_or_client_learned_peer_id(), connection_or_report_broken_states(), connection_printf_to_buf(), connection_read_https_proxy_response(), connection_read_proxy_handshake(), connection_socks4_proxy_connect(), consdiff_apply_diff(), consdiff_get_digests(), consensus_cache_delete_pending(), consensus_cache_entry_decref(), consensus_cache_free_(), consensus_cache_open(), consensus_compress_worker_job_free_(), consensus_diff_worker_job_free_(), consensus_diff_worker_threadfn(), consensus_queue_compression_work(), control_cmd_args_free_(), control_cmd_parse_args(), control_event_address_mapped(), control_event_bootstrap_problem(), control_event_circ_bandwidth_used_for_circ(), control_event_circuit_cell_stats(), control_event_circuit_status(), control_event_circuit_status_minor(), control_event_conf_changed(), control_event_descriptors_changed(), control_event_hs_descriptor_content(), control_event_hs_descriptor_created(), control_event_hs_descriptor_requested(), control_event_hs_descriptor_upload(), control_event_hs_descriptor_upload_end(), control_event_hsv3_descriptor_failed(), control_event_logmsg(), control_event_networkstatus_changed_helper(), control_event_status(), control_event_stream_status(), control_ports_write_to_file(), control_reply_add_printf(), control_setconf_helper(), control_vprintf_reply(), control_write_data(), control_write_reply_line(), controller_get_routerdescs(), countbytes_close_fn(), cpath_free(), cpuworker_cancel_circ_handshake(), cpuworker_onion_handshake_replyfn(), create_managed_proxy_environment(), create_rend_cpath(), crypto_dh_compute_secret(), crypto_dh_free_(), crypto_dh_new(), crypto_digest_free_(), crypto_digest_new_internal(), crypto_expand_key_material_TAP(), crypto_ope_free_(), crypto_openssl_free_all(), crypto_pk_base64_decode_private(), crypto_pk_base64_encode_private(), crypto_pk_free_(), crypto_pk_get_common_digests(), crypto_pk_get_digest(), crypto_pk_obsolete_private_hybrid_decrypt(), crypto_pk_obsolete_public_hybrid_encrypt(), crypto_pk_public_checksig_digest(), crypto_pk_read_from_string_generic(), crypto_pk_read_private_key_from_filename(), crypto_pk_write_private_key_to_filename(), crypto_pk_write_to_string_generic(), crypto_pwbox(), crypto_random_hostname(), crypto_read_tagged_contents_from_file(), crypto_unpwbox(), crypto_xof_free_(), curve25519_keypair_read_from_file(), dcfg_free_(), ddmap_entry_free_(), decode_create2_list(), decode_hashed_passwords(), decode_intro_points(), decode_link_specifiers(), decode_pow_params(), decrypt_desc_layer(), decrypt_descriptor_cookie(), decrypt_introduce2(), dequeue_timestamp(), desc_decode_encrypted_v3(), desc_decode_superencrypted_v3(), desc_decrypt_encrypted(), desc_encode_v3(), destroy_cell_queue_clear(), destroy_cell_to_packed_cell(), dimap_free_(), dir_server_free_(), dir_split_resource_into_fingerprint_pairs(), dir_split_resource_into_fingerprints(), dir_split_resource_into_spoolable(), dirauth_options_validate(), dirclient_dump_total_dls(), dircollator_free_(), directory_get_consensus_url(), directory_handle_command(), directory_handle_command_get(), directory_handle_command_post(), directory_post_to_dirservers(), directory_request_free_(), directory_send_command(), dirserv_add_descriptor(), dirserv_compute_performance_thresholds(), dirserv_expire_measured_bw_cache(), dirserv_free_fingerprint_list(), dirserv_generate_networkstatus_vote_obj(), dirserv_load_fingerprint_file(), dirserver_choose_by_weight(), dirvote_act(), dirvote_add_signatures_to_all_pending_consensuses(), dirvote_add_signatures_to_pending_consensus(), dirvote_add_vote(), dirvote_clear_pending_consensuses(), dirvote_clear_votes(), dirvote_compute_consensuses(), dirvote_compute_params(), dirvote_create_microdescriptor(), dirvote_fetch_missing_votes(), dirvote_format_all_microdesc_vote_lines(), dirvote_format_microdesc_vote_line(), dirvote_free_all(), dirvote_perform_vote(), disk_state_load_from_disk(), disk_state_load_from_disk_impl(), disk_state_parse_commits(), disk_state_parse_sr_values(), disk_state_parse_srv(), disk_state_put_commit_line(), disk_state_reset(), disk_state_save_to_disk(), dispatch_free_(), dispatch_free_msg_(), dispatch_send_msg_unchecked(), dispatcher_run_msg_cbs(), dns_cancel_pending_resolve(), dns_free_all(), dns_reset(), dns_reset_correctness_checks(), dns_resolve(), dnsserv_launch_request(), dnsserv_resolved(), do_dump_config(), do_hup(), do_keygen_family(), document_signature_free_(), dump_desc(), dump_desc_create_dir(), dump_desc_fifo_add_and_clean(), dump_desc_fifo_cleanup(), dump_desc_init(), dump_desc_populate_fifo_from_directory(), dump_desc_populate_one_file(), ed25519_checksig_batch(), ed25519_checksig_prefixed(), ed25519_keypair_free_(), ed25519_pubkey_read_from_file(), ed25519_seckey_read_from_file(), ed25519_sign_prefixed(), ed_key_init_from_file(), ed_key_new(), encode_client_auth_cred_for_control_port(), encode_enc_key(), encode_intro_point(), encode_legacy_key(), encode_link_specifiers(), encode_protocol_list(), encode_superencrypted_data(), encrypt_desc_data_and_base64(), encrypt_descriptor_data(), entry_connection_describe_status_for_controller(), entry_guard_add_to_sample_impl(), entry_guard_encode_for_state(), entry_guard_free_(), entry_guard_parse_from_state(), entry_guard_restriction_free_(), esc_for_log_len(), esc_router_info(), escaped(), evdns_callback(), evdns_log_cb(), evdns_server_callback(), evdns_wildcard_check_callback(), event_hs_descriptor_receive_end(), ewma_free_circ_data(), ewma_free_cmux_data(), expand_filename(), expire_old_onion_keys(), export_consensus_for_transparency(), ext_or_cmd_free_(), ext_orport_free_all(), extend_info_free_(), extrainfo_dump_to_string(), extrainfo_dump_to_string_header_helper(), extrainfo_free_(), fast_client_handshake(), fast_handshake_state_free_(), fast_server_handshake(), file_status(), fill_dns_error_values(), fill_dns_query_values(), fill_onionskins_values(), find_and_remove_client_auth_creds_file(), find_my_address(), find_torrc_filename(), format_cell_stats(), format_labels(), format_networkstatus_vote(), format_protocols_lines_for_vote(), format_recommended_version_list(), fp_pair_map_free_(), fp_pair_map_iter_next_rmv(), fp_pair_map_remove(), frac_nodes_with_descriptors(), free_cached_resolve_(), free_execve_args(), free_or_history(), free_pending_rend(), gen_ed_diff(), geoip_bridge_stats_write(), geoip_dirreq_stats_write(), geoip_entry_stats_write(), geoip_format_bridge_stats(), geoip_format_dirreq_stats(), geoip_format_entry_stats(), geoip_get_client_history(), geoip_get_request_history(), geoip_get_transport_history(), geoip_load_file(), geoip_reset_dirreq_stats(), geoip_stats_free_all(), get_address_from_config(), get_all_auth_client_lines(), get_bindaddr_for_server_proxy(), get_bindaddr_from_transport_listen_line(), get_client_auth_creds_filename(), get_configured_bridge_by_routerinfo(), get_creds_from_client_auth_filename(), get_data_directory(), get_esc_cfile(), get_glob_paths(), get_inner_encrypted_layer_plaintext(), get_interface_address6_list(), get_introduce2_key_material(), get_introduce2_keys_and_verify_mac(), get_my_declared_family(), get_ns_str_from_sr_values(), get_options_from_transport_options_line(), get_outer_encrypted_layer_plaintext(), get_total_system_memory_impl(), get_transport_bindaddr(), get_transport_in_state_by_name(), get_transport_options_for_server_proxy(), get_unique_circ_id_by_chan(), get_unquoted_path(), getinfo_helper_config(), getinfo_helper_dir(), getinfo_helper_downloads(), getinfo_helper_entry_guards(), getinfo_helper_events(), getinfo_helper_listeners(), getinfo_helper_networkstatus(), getinfo_helper_policies(), guard_selection_free_(), half_edge_free_(), handle_control_add_onion(), handle_control_authchallenge(), handle_control_authenticate(), handle_control_del_onion(), handle_control_extendcircuit(), handle_control_getconf(), handle_control_getinfo(), handle_control_loadconf(), handle_control_mapaddress(), handle_control_obsolete(), handle_control_onion_client_auth_add(), handle_control_onion_client_auth_view(), handle_control_redirectstream(), handle_get_keys(), handle_get_networkstatus_bridges(), handle_get_next_bandwidth(), handle_introduce1(), handle_missing_protocol_warning_impl(), handle_relay_msg(), handle_response_fetch_consensus(), handle_response_fetch_desc(), handle_response_fetch_microdesc(), handle_response_upload_dir(), handle_single_control_command(), host_header_is_localhost(), hs_cell_parse_introduce2(), hs_circuitmap_free_all(), hs_clean_last_hid_serv_requests(), hs_config_client_authorization(), hs_desc_authorized_client_free_(), hs_desc_build_authorized_client(), hs_desc_encrypted_data_free_(), hs_desc_encrypted_data_free_contents(), hs_desc_intro_point_free_(), hs_desc_plaintext_data_free_(), hs_desc_plaintext_data_free_contents(), hs_desc_superencrypted_data_free_(), hs_desc_superencrypted_data_free_contents(), hs_descriptor_free_(), hs_ident_circuit_free_(), hs_ident_dir_conn_free_(), hs_ident_edge_conn_free_(), hs_intro_send_intro_established_cell(), hs_lookup_last_hid_serv_request(), hs_ob_parse_config_file(), hs_ob_refresh_keys(), hs_parse_port_config(), hs_port_config_free_(), hs_pow_free_service_state(), hs_pow_solve(), hs_pow_verify(), hs_purge_hid_serv_from_last_hid_serv_requests(), hs_service_add_ephemeral(), hs_service_free_(), hs_token_free_(), hs_v2_stats_free_(), hs_v3_stats_free_(), http_set_address_origin(), inform_pending_connections(), init_cookie_authentication(), init_curve25519_keypair_from_file(), init_keys(), initiate_descriptor_downloads(), interface_address6_list_free_(), introduce1_encrypt_and_encode(), keypin_add_or_replace_entry_in_map(), keypin_clear(), keypin_parse_journal_line(), kvline_encode(), kvline_parse(), launch_managed_proxy(), launch_one_resolve(), launch_wildcard_check(), lcs_lengths(), learned_router_identity(), leg_free(), link_specifier_dup(), list_family_key_files_impl(), list_getinfo_options(), list_pending_downloads(), list_pending_fpsk_downloads(), list_v3_auth_ids(), load_authority_keyset(), load_client_keys(), load_ed_keys(), load_family_id_keys_impl(), load_service_keys(), load_stats_file(), load_torrc_from_disk(), log_buggy_rs_source(), log_cert_lifetime(), log_credential_status(), log_free_(), log_heartbeat(), log_master_signing_key_cert_expiration(), log_set_application_name(), logfile_deliver(), logs_free_all(), machine_spec_free_(), mainloop_event_free_(), make_consensus_method_list(), make_path_absolute(), managed_proxy_destroy(), managed_var_free_(), measured_bw_line_parse(), memarea_chunk_free_unchecked(), memarea_drop_all_(), metrics_connection_process_inbuf(), metrics_parse_ports(), metrics_store_entry_free_(), metrics_store_free_(), microdesc_cache_rebuild(), microdesc_cache_reload(), microdesc_free_(), microdesc_free_all(), microdesc_reset_outdated_dirservers_list(), microdesc_wipe_body(), microdescs_add_to_cache(), monitor_owning_controller_process(), munge_extrainfo_into_routerinfo(), namemap_clear(), networkstatus_check_consensus_signature(), networkstatus_check_document_signature(), networkstatus_check_required_protocols(), networkstatus_compute_consensus(), networkstatus_format_signatures(), networkstatus_get_detached_signatures(), networkstatus_getinfo_by_purpose(), networkstatus_map_cached_consensus_impl(), networkstatus_note_certs_arrived(), networkstatus_parse_detached_signatures(), networkstatus_parse_vote_from_string(), networkstatus_set_current_consensus(), networkstatus_vote_free_(), node_free_(), node_log_dup_ed_id(), nodefamily_canonicalize(), nodefamily_format(), nodefamily_free_(), nodefamily_from_members(), nodelist_free_all(), normalize_nickname_list(), ns_detached_signatures_free_(), ntor3_handshake_state_free_(), ntor3_server_handshake_state_free_(), ntor_handshake_state_free_(), ntor_key_map_free_helper(), ob_option_parse(), onion_ntor3_client_handshake(), onion_pending_add(), onion_queue_entry_remove(), onion_skin_client_handshake(), onion_skin_create(), onion_skin_ntor3_create_nokeygen(), onion_skin_ntor3_server_handshake_part1(), onion_skin_ntor3_server_handshake_part2_nokeygen(), onion_skin_ntor_create(), onion_skin_server_handshake(), options_act(), options_act_relay_dir(), options_clear_cb(), options_commit_listener_transaction(), options_commit_log_transaction(), options_init(), options_init_from_string(), options_init_from_torrc(), options_init_logs(), options_rollback_listener_transaction(), options_rollback_log_transaction(), options_validate_cb(), options_validate_relay_mode(), options_validate_server_transport(), or_handshake_certs_free_(), or_handshake_state_free_(), or_state_load(), or_state_save(), or_state_save_broken(), or_state_set(), packed_cell_free_unchecked(), parse_accept_encoding_header(), parse_addr_policy(), parse_auth_file_content(), parse_authorized_client(), parse_bridge_line(), parse_consensus_request(), parse_dir_authority_line(), parse_dir_fallback_line(), parse_dirauth_dirport(), parse_from_state_set_vals(), parse_http_response(), parse_http_url(), parse_iso_time_(), parse_log_line(), parse_log_severity_config(), parse_method_line_helper(), parse_or_diff_from_header(), parse_private_key_from_control_port(), parse_rfc1123_time(), parse_socks(), parse_socks4_request(), parse_socks5_userpass_auth(), parse_status_line(), parse_tcp_proxy_line(), parsed_cmdline_free_(), parsed_consensus_request_clear(), pathbias_count_build_attempt(), pathbias_count_build_success(), pathbias_send_usable_probe(), pathbias_should_count(), pem_decode(), pending_log_message_free_(), periodic_timer_free_(), periodic_timer_new(), policies_parse_exit_policy_from_options(), policy_dump_to_string(), policy_summarize(), port_cfg_free_(), port_cfg_line_extract_addrport(), port_parse_config(), pow_worker_job_free(), pow_worker_threadfn(), predicted_ports_free_all(), process_environment_free_(), process_free_(), process_read_buffer(), process_read_lines(), process_reset_environment(), process_unix_exec(), process_unix_free_(), process_vprintf(), proto_entry_free_(), proxy_needs_restart(), proxy_prepare_for_restart(), pt_get_extra_info_descriptor_string(), pt_parse_transport_line(), pt_prepare_proxy_list_for_config_read(), pt_stringify_socks_args(), pt_update_bridge_lines(), pubsub_adjmap_free_(), pubsub_adjmap_free_helper(), pubsub_builder_free_(), pubsub_connector_free_(), pubsub_items_free_(), purge_expired_resolves(), queue_control_event_string(), queued_event_free_(), reachability_warnings_callback(), read_bandwidth_usage(), read_file_to_str_until_eof(), relay_config_free_all(), relay_msg_free_(), relay_send_command_from_edge_(), reload_consensus_from_file(), remember_failing_intro_point(), remove_all_entry_guards_for_guard_selection(), remove_duplicate_orports(), remove_expired_failing_intro(), rep_hist_buffer_stats_write(), rep_hist_desc_stats_write(), rep_hist_exit_stats_term(), rep_hist_exit_stats_write(), rep_hist_format_buffer_stats(), rep_hist_format_desc_stats(), rep_hist_format_exit_stats(), rep_hist_free_all(), rep_hist_get_overload_stats_lines(), rep_hist_get_predicted_ports(), rep_hist_hs_stats_write(), rep_hist_load_mtbf_data(), rep_hist_log_link_protocol_counts(), rep_hist_record_mtbf_data(), rep_hist_remove_predicted_ports(), rep_hist_reset_buffer_stats(), replaycache_free_(), replaycache_scrub_if_needed_internal(), replyqueue_free_(), retry_all_listeners(), rotate_onion_key(), router_append_dirobj_signature(), router_build_fresh_unsigned_routerinfo(), router_dump_router_to_string(), router_free_all(), router_get_dirobj_signature(), router_load_extrainfo_from_string(), router_load_routers_from_string(), router_orport_found_reachable(), router_rebuild_store(), router_reload_consensus_networkstatus(), router_reload_router_list_impl(), router_reset_warnings(), router_upload_dir_desc_to_dirservers(), router_write_fingerprint(), routerinfo_free_(), routerinfo_incompatible_with_extrainfo(), routerlist_free_(), routerlist_free_all(), routerlist_remove_old_cached_routers_with_id(), routerlist_reset_warnings(), routerset_free_(), routerset_parse(), routerset_union(), routerstatus_format_entry(), routerstatus_free_(), save_transport_to_state(), secret_to_key_rfc2440(), send_introduce_ack_cell(), server_onion_keys_free_(), service_authorized_client_free_(), service_clear_config(), service_desc_clear_previous_hsdirs(), service_descriptor_free_(), service_free_all(), service_intro_point_free_(), service_key_on_disk(), short_policy_free_(), should_service_upload_descriptor(), signed_desc_append_to_journal(), signed_descriptor_free_(), signed_descriptor_reset(), smartlist_choose_node_by_bandwidth_weights(), smartlist_free_(), smartlist_string_remove(), socks_request_free_(), spawn_func(), spooled_resource_free_(), sr_commit_free_(), sr_compute_srv(), sr_get_string_for_vote(), sr_parse_srv(), start_writing_to_file(), state_free_(), state_query_del_(), state_transport_line_is_valid(), storage_dir_clean_tmpfiles(), storage_dir_free_(), storage_dir_get_usage(), storage_dir_map(), storage_dir_read(), storage_dir_register_with_sandbox(), storage_dir_remove_file(), storage_dir_rescan(), storage_dir_save_chunks_to_file(), storage_dir_shrink(), store_permanent_client_auth_credentials(), string_is_valid_dest(), string_is_valid_nonrfc_hostname(), strmap_remove_lc(), tell_controller_about_resolved_result(), threadpool_free_(), threadpool_queue_update(), timer_free_(), tor_addr_parse_impl(), tor_addr_parse_mask_ports(), tor_addr_port_lookup(), tor_addr_port_parse(), tor_addr_port_split(), tor_assertion_failed_(), tor_bug_occurred_(), tor_cert_create_raw(), tor_cert_free_(), tor_cleanup(), tor_compress_free_(), tor_compress_impl(), tor_compress_new(), tor_cond_free_(), tor_cond_new(), tor_free_(), tor_getpass(), tor_glob(), tor_gmtime_r(), tor_inet_aton(), tor_listdir(), tor_localtime_r(), tor_lockfile_unlock(), tor_lzma_compress_free_(), tor_lzma_compress_new(), tor_munmap_anonymous(), tor_mutex_free_(), tor_passwd_free_(), tor_process_monitor_free_(), tor_process_monitor_poll_cb(), tor_pthread_helper_fn(), tor_run_main(), tor_tls_context_decref(), tor_tls_context_init_certificates(), tor_tls_free_(), tor_tls_new(), tor_tls_set_logged_address(), tor_vasprintf(), tor_version_is_obsolete(), tor_x509_cert_free_(), tor_zlib_compress_free_(), tor_zlib_compress_new(), tor_zstd_compress_free_(), tor_zstd_compress_new(), transport_free_(), transport_resolve_conflicts(), trusted_dir_server_new(), trusted_dirs_flush_certs_to_disk(), trusted_dirs_reload_certs(), try_locking(), typed_var_copy(), typed_var_eq(), typed_var_kvassign(), unescape_string(), unglob_opened_files(), unlinked_circuit_free(), unlinked_free(), update_all_descriptors_pow_params(), update_router_have_minimum_dir_info(), upload_descriptor_to_hsdir(), using_old_proxy_auth(), validate_data_directories(), validate_transport_socks_arguments(), var_cell_free_(), vote_routerstatus_free_(), voting_schedule_free_(), warn_consensus_is_not_reasonably_live(), warn_early_consensus(), warn_if_option_path_is_relative(), workerthread_free_(), workqueue_entry_free_(), write_address_to_file(), write_configuration_file(), write_short_http_response(), write_short_policy(), write_str_to_file_if_not_equal(), and write_to_data_subdir().

◆ tor_malloc

#define tor_malloc ( size)
Value:
void * tor_malloc_(size_t size) ATTR_MALLOC
Definition malloc.c:32

Definition at line 62 of file malloc.h.

◆ tor_malloc_zero

#define tor_malloc_zero ( size)
Value:
void * tor_malloc_zero_(size_t size) ATTR_MALLOC
Definition malloc.c:63

Definition at line 63 of file malloc.h.

◆ tor_memdup

#define tor_memdup ( s,
n )
Value:
void * tor_memdup_(const void *mem, size_t len) ATTR_MALLOC
Definition malloc.c:200

Definition at line 70 of file malloc.h.

◆ tor_memdup_nulterm

#define tor_memdup_nulterm ( s,
n )
Value:
void * tor_memdup_nulterm_(const void *mem, size_t len) ATTR_MALLOC
Definition malloc.c:213

Definition at line 71 of file malloc.h.

◆ tor_realloc

#define tor_realloc ( ptr,
size )
Value:
tor_realloc_(ptr, size)
void * tor_realloc_(void *ptr, size_t size)
Definition malloc.c:118

Definition at line 65 of file malloc.h.

◆ tor_reallocarray

#define tor_reallocarray ( ptr,
sz1,
sz2 )
Value:
tor_reallocarray_((ptr), (sz1), (sz2))
void * tor_reallocarray_(void *ptr, size_t size1, size_t size2)
Definition malloc.c:146

Definition at line 66 of file malloc.h.

◆ tor_strdup

#define tor_strdup ( s)
Value:
char * tor_strdup_(const char *s) ATTR_MALLOC
Definition malloc.c:160

Definition at line 68 of file malloc.h.

◆ tor_strndup

#define tor_strndup ( s,
n )
Value:
char * tor_strndup_(const char *s, size_t n) ATTR_MALLOC
Definition malloc.c:182

Definition at line 69 of file malloc.h.

Function Documentation

◆ tor_calloc_()

void * tor_calloc_ ( size_t nmemb,
size_t size )

Allocate a chunk of nmemb*size bytes of memory, fill the memory with zero bytes, and return a pointer to the result. Log and terminate the process on error. (Same as calloc(nmemb,size), but never returns NULL.) The second argument (size) should preferably be non-zero and a compile-time constant.

Definition at line 107 of file malloc.c.

◆ tor_free_()

◆ tor_malloc_()

void * tor_malloc_ ( size_t size)

Allocate a chunk of size bytes of memory, and return a pointer to result. On error, log and terminate the process. (Same as malloc(size), but never returns NULL.)

Definition at line 32 of file malloc.c.

Referenced by tor_malloc_zero_(), tor_memdup_(), tor_memdup_nulterm_(), tor_run_main(), and tor_strndup_().

◆ tor_malloc_zero_()

void * tor_malloc_zero_ ( size_t size)

Allocate a chunk of size bytes of memory, fill the memory with zero bytes, and return a pointer to the result. Log and terminate the process on error. (Same as calloc(size,1), but never returns NULL.)

Definition at line 63 of file malloc.c.

Referenced by tor_calloc_().

◆ tor_memdup_()

void * tor_memdup_ ( const void * mem,
size_t len )

Allocate a chunk of len bytes, with the same contents as the len bytes starting at mem.

Definition at line 200 of file malloc.c.

◆ tor_memdup_nulterm_()

void * tor_memdup_nulterm_ ( const void * mem,
size_t len )

As tor_memdup(), but add an extra 0 byte at the end of the resulting memory.

Definition at line 213 of file malloc.c.

◆ tor_realloc_()

void * tor_realloc_ ( void * ptr,
size_t size )

Change the size of the memory block pointed to by ptr to size bytes long; return the new memory block. On error, log and terminate. (Like realloc(ptr,size), but never returns NULL.)

Definition at line 118 of file malloc.c.

Referenced by tor_run_main().

◆ tor_reallocarray_()

void * tor_reallocarray_ ( void * ptr,
size_t sz1,
size_t sz2 )

Try to realloc ptr so that it takes up sz1 * sz2 bytes. Check for overflow. Unlike other allocation functions, return NULL on overflow.

Definition at line 146 of file malloc.c.

◆ tor_strdup_()

char * tor_strdup_ ( const char * s)

Return a newly allocated copy of the NUL-terminated string s. On error, log and terminate. (Like strdup(s), but never returns NULL.)

Definition at line 160 of file malloc.c.

◆ tor_strndup_()

char * tor_strndup_ ( const char * s,
size_t n )

Allocate and return a new string containing the first n characters of s. If s is longer than n characters, only the first n are copied. The result is always NUL-terminated. (Like strndup(s,n), but never returns NULL.)

Definition at line 182 of file malloc.c.