Rizin
unix-like reverse engineering framework and cli tools
malloc.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <dlfcn.h>
#include "config.h"

Go to the source code of this file.

Macros

#define __USE_GNU
 
#define RTLD_NEXT   RTLD_DEFAULT
 

Functions

const char * getprogname (void)
 
static void init (void)
 
void * calloc (size_t number, size_t size)
 
void * malloc (size_t size)
 
void * realloc (void *ptr, size_t size)
 

Variables

static int inited = 0
 
static size_t count = 0
 
static size_t max_count = 0
 
static size_t min_size = 0
 
static void *(* real_malloc )(size_t size) = NULL
 
static void *(* real_calloc )(size_t number, size_t size) = NULL
 
static void *(* real_realloc )(void *ptr, size_t size) = NULL
 
static const char * myname = NULL
 

Macro Definition Documentation

◆ __USE_GNU

#define __USE_GNU

Definition at line 38 of file malloc.c.

◆ RTLD_NEXT

#define RTLD_NEXT   RTLD_DEFAULT

Definition at line 45 of file malloc.c.

Function Documentation

◆ calloc()

void* calloc ( size_t  number,
size_t  size 
)

Definition at line 102 of file malloc.c.

102  {
103  void *ret;
104 
105  if (!inited) {
106  init();
107  }
108 
109  if (number >= min_size / size && count >= max_count) {
110  errno = ENOMEM;
111  return NULL;
112  }
113 
114  ret = real_calloc(number, size);
115  if (size >= min_size) {
116  count++;
117  }
118 
119  return ret;
120 }
#define NULL
Definition: cris-opc.c:27
voidpf void uLong size
Definition: ioapi.h:138
static void *(* real_calloc)(size_t number, size_t size)
Definition: malloc.c:70
static void init(void)
Definition: malloc.c:80
static size_t count
Definition: malloc.c:66
static int inited
Definition: malloc.c:65
static size_t max_count
Definition: malloc.c:67
static size_t min_size
Definition: malloc.c:68
#define ENOMEM
Definition: sftypes.h:122

References count, ENOMEM, init(), inited, max_count, min_size, NULL, and real_calloc.

Referenced by __analysis_esil_function(), __core_cmd_search_asm_infinite(), __init_panels(), __init_panels_menu(), __open(), __printPattern(), __rap_system(), __read(), __reg_read(), __renew_filter(), _analysis_calls(), _cb_hit(), _createKDNetPacket(), _extract_flags(), _extract_regs(), _parse_resource_directory(), _sendResponsePacket(), _server_handle_P(), _zip_crypto_aes_new(), _zip_crypto_hmac_new(), agraph_print_edges(), alloc_instr(), analBars(), analysis_fcn_data(), annotated_hexdump(), apprentice_load(), been_here(), bin_pe_dotnet_init_metadata(), bin_pe_versioninfo(), build_hash_table(), cdb_init(), cmd_debug_cont_syscall(), cmd_print_bars(), cmd_print_format(), construct_rop_gadget(), cris_parse_disassembler_options(), de_bruijn(), dem_str_newf(), do_syscall_search(), ds_print_ptr(), emit_string(), file_ascmagic(), fill_block_data(), fuzzerTests(), gdbr_attach(), gdbr_detach_pid(), gdbr_init(), gdbr_kill_pid(), gdbr_open_file(), gdbr_send_qRcmd(), gdbr_write_bin_registers(), gdbr_write_memory(), gdbr_write_registers(), get_AR_regs_class1(), get_imports(), get_ivar_list_t(), get_libs(), get_objc_property_list(), get_opcode_entry(), get_proper_name(), get_relocs(), get_section_bytes(), get_sections(), get_sim_reg(), get_symbols(), get_symbols_list(), GetHeapBlocks(), handle_stop_reason(), hash_resize(), hex_extend_op(), hexagon_get_state(), HtName_(), http_logf(), ihex_parse(), init_abbrev_decl(), init_comp_unit(), init_debug_abbrev(), init_die(), init_items(), inithist(), ioMemcpy(), is_string_at(), kexts_from_load_commands(), lang_byte_array_nodejs(), le_read_nonnull_str_at(), load_buffer(), LZ4_calloc(), main(), mpc_err_string(), mpc_input_mark(), mpc_undefined(), mpcf_ctor_str(), mpcf_escape_new(), mpcf_re_range(), mpcf_strfold(), mpcf_unescape_new(), objc_build_refs(), palloc(), parse_attr_value(), parse_dysymtab(), parse_function_starts(), parse_line_header(), parse_relocation_info(), parse_signature(), parse_symbol_table(), parse_symtab(), parseCodeDirectory(), Pe_r_bin_pe_parse_string(), Pe_r_bin_pe_parse_string_file_info(), Pe_r_bin_pe_parse_string_table(), Pe_r_bin_pe_parse_var(), Pe_r_bin_pe_parse_var_file_info(), Pe_r_bin_pe_parse_version_info(), print_heap_chunk(), print_hex_from_base2(), process_constructors(), qnxr_init(), rabin_dump_symbols(), raw_rtti_parse(), rax(), read_n_bits(), read_str(), ReadMemory(), reconstruct_chained_fixup(), relocs_foreach(), rtti_itanium_vmi_class_type_info_init(), run_old_command(), rz_alloc_init(), rz_analysis_esil_new(), rz_analysis_functions_map_handler(), rz_analysis_get_jmptbl_info(), rz_analysis_op_hexstr(), rz_analysis_vtable_parse_at(), rz_analysis_walkthrough_casetbl(), rz_analysis_walkthrough_jmptbl(), rz_asm_code_get_hex(), rz_asm_disassemble(), rz_asm_massemble(), rz_asm_op_get_hex(), rz_asn1_create_binary(), rz_asn1_stringify_oid(), rz_assembly_of_hex_handler(), rz_base64_decode_dyn(), rz_big_to_hexstr(), rz_bin_coff_init_scn_hdr(), rz_bin_coff_init_symtable(), rz_bin_dmp64_init_bmp_header(), rz_bin_dmp64_init_memory_runs(), rz_bin_dmp64_init_triage_drivers(), rz_bin_le_new_buf(), rz_bin_mz_get_relocs(), rz_bin_ne_buf_init(), rz_bin_ne_get_relocs(), rz_bin_pe_get_debug_data(), rz_bin_pe_get_libs(), rz_bin_pe_get_sections(), rz_bin_pemixed_init_native(), rz_bin_te_get_sections(), rz_bitmap_new(), rz_bp_add(), rz_bp_add_sw(), rz_cf_value_data_new(), rz_cmd_analysis(), rz_cmd_heap_chunks_print_handler(), rz_cmd_help(), rz_cmd_print(), rz_cmd_search(), rz_cons_canvas_to_string(), rz_cons_grep_line(), rz_cons_grepbuf(), rz_cons_less_str(), rz_cons_rainbow_new(), rz_cons_rgb_str_mode(), rz_core_analysis_bytes(), rz_core_asm_strsearch(), rz_core_cmp_disasm(), rz_core_hack_arm(), rz_core_init(), rz_core_rtr_cmd(), rz_core_search_rop(), rz_core_serve(), rz_core_shift_block(), rz_core_visual_colors(), rz_core_visual_panels_root(), rz_core_write_base64_at(), rz_core_yank_string(), rz_debug_gdb_reg_read(), rz_debug_qnx_reg_read(), rz_debug_reg_sync(), rz_egg_Cfile_set_cEnv(), rz_esil_of_hex_handler(), rz_file_tmpdir(), rz_hash_cfg_randomart(), rz_hex_no_code(), rz_io_cache_write(), rz_io_desc_cache_list(), rz_io_shift(), rz_io_zip_slurp_file(), rz_lib_dl_open(), rz_list_iter_new(), rz_mem_alloc(), rz_parse_filter_dup(), rz_pkcs7_parse_certificaterevocationlists(), rz_pkcs7_parse_digestalgorithmidentifier(), rz_pkcs7_parse_extendedcertificatesandcertificates(), rz_pkcs7_parse_signerinfos(), rz_print_areas_no_functions_handler(), rz_print_delta_pointer_table_handler(), rz_print_hexdump_hexless_words_handler(), rz_print_hexpair(), rz_punycode_decode(), rz_punycode_encode(), rz_reg_arena_new(), rz_reg_arena_shrink(), rz_reg_read_regs(), rz_reg_set_bytes(), rz_regex_comp(), rz_scan_strings(), rz_scan_strings_raw(), rz_socket_http_accept(), rz_socket_rap_client_command(), rz_str_ansi_filter(), rz_str_appendf(), rz_str_from_ut64(), rz_str_mb_to_wc_l(), rz_str_newf(), rz_str_utf16_decode(), rz_subprocess_start_opt(), rz_syscall_item_new_from_string(), rz_syscmd_ls(), rz_table_columns(), rz_test_main(), rz_type_format_data_internal(), rz_x509_parse_crl(), rz_x509_parse_extensions(), rz_x509_parse_name(), rzfind_open_file(), rzpipe_read(), sdb_decode(), sdb_encode(), sdb_expire_set(), sdb_like(), sdb_querys(), sdb_text_load(), search_collisions(), search_similar_pattern_in(), sections(), setup_workers(), slurp(), spp_io(), str_dup_safe_fixed(), strbuf_new(), string_scan_range(), string_scan_range_cfstring(), symbols(), tokenize(), ts_calloc_default(), ts_node_children_wasm(), ts_node_named_children_wasm(), ts_parser_new_wasm(), update(), use_stdin(), utf32toutf8(), utf8toutf32(), v_writebuf(), w32_dbg_wait(), w32dbg_wrap_new(), walk_exports(), wasm_dis(), winkd_get_thread_at(), winkd_list_modules(), write_n_bits(), WriteMemory(), xnu_dbg_modules(), xnu_generate_corefile(), xtensa_isa_init(), and zcalloc().

◆ getprogname()

const char* getprogname ( void  )

Definition at line 56 of file malloc.c.

56  {
57 #if defined(HAVE___PROGNAME)
58  return __progname;
59 #else
60  return NULL;
61 #endif
62 }

References NULL.

Referenced by init().

◆ init()

static void init ( void  )
static

Definition at line 80 of file malloc.c.

80  {
81  char *foo;
82  myname = getprogname();
83  if (!myname)
84  myname = "(unknown)";
85  if ((foo = getenv("MALLOC_MAX_COUNT")) != NULL)
86  max_count = strtoul(foo, NULL, 0);
87  if ((foo = getenv("MALLOC_MIN_SIZE")) != NULL)
88  min_size = strtoul(foo, NULL, 0);
89  real_calloc = dlsym(RTLD_NEXT, "calloc");
90  if (!real_calloc)
91  abort();
92  real_malloc = dlsym(RTLD_NEXT, "malloc");
93  if (!real_malloc)
94  abort();
95  real_realloc = dlsym(RTLD_NEXT, "realloc");
96  if (!real_realloc)
97  abort();
98  inited = 1;
99 }
static RzMain foo[]
Definition: main.c:11
static void *(* real_malloc)(size_t size)
Definition: malloc.c:69
const char * getprogname(void)
Definition: malloc.c:56
static const char * myname
Definition: malloc.c:73
#define RTLD_NEXT
Definition: malloc.c:45
static void *(* real_realloc)(void *ptr, size_t size)
Definition: malloc.c:71
char * getenv()

References foo, getenv(), getprogname(), inited, max_count, min_size, myname, NULL, real_calloc, real_malloc, real_realloc, and RTLD_NEXT.

Referenced by calloc(), malloc(), and realloc().

◆ malloc()

void* malloc ( size_t  size)

Definition at line 123 of file malloc.c.

123  {
124  void *ret;
125 
126  if (!inited) {
127  init();
128  }
129 
130  if (size >= min_size && count >= max_count) {
131  errno = ENOMEM;
132  return NULL;
133  }
134 
135  ret = real_malloc(size);
136  if (size >= min_size) {
137  count++;
138  }
139 
140  return ret;
141 }

References count, ENOMEM, init(), inited, max_count, min_size, NULL, and real_malloc.

Referenced by __analysis_fcn_check_bp_use(), __apply_filter_cmd(), __desc_cache_list_cb(), __drv_when(), __dumpSections(), __expandLine(), __filterQuotedShell(), __malloc0(), __open(), __read_nonnull_str_at(), __resize(), __resize_panel_down(), __resize_panel_left(), __resize_panel_right(), __resize_panel_up(), __write(), _analysis_calls(), _cb_hit(), _getopt_initialize(), _server_handle_exec_file_read(), _server_handle_g(), _server_handle_M(), _server_handle_m(), _server_handle_qC(), _server_handle_qfThreadInfo(), _server_handle_qSupported(), _write_asm(), _zip_buffer_new(), _zip_cdir_new(), _zip_cp437_to_utf8(), _zip_crypto_aes_new(), _zip_crypto_hmac_new(), _zip_dirent_clone(), _zip_dirent_new(), _zip_ef_new(), _zip_file_new(), _zip_hash_add(), _zip_hash_new(), _zip_memdup(), _zip_new(), _zip_progress_new(), _zip_read_data(), _zip_source_new(), _zip_source_window_new(), _zip_string_new(), _zip_winzip_aes_new(), add_fi(), add_filter(), addpoint(), address_bit(), alloc_buffer(), allocate(), analysis_mask(), analysis_mask_avr(), ansi_allocate_tempname(), apprentice_1(), apprentice_load(), apprentice_map(), aprintf(), ar_parse_header(), arch_parse_reg_profile(), avr_custom_spm_page_write(), backtrace_fuzzy(), basicTests(), bbget(), bfvm_init(), bin_pe_get_actual_checksum(), bin_pe_init_exports(), bin_pe_init_hdr(), bin_pe_init_resource(), bin_pe_init_sections(), bin_pe_init_security(), block_load_cb(), BMK_benchFiles(), BMK_benchFileTable(), BMK_benchMem(), BMK_findMaxMem(), BMK_syntheticTest(), bochs_open(), bopen(), bsd_desc_list(), bsd_native_sysctl_map(), bsd_thread_list(), buf_bytes_init(), buf_read(), buffer_new(), buffer_read_file(), buffer_write(), cabx_alloc(), cabx_open(), calculate_decrypt(), calculate_encrypt(), calculate_hash(), carve_deps_at_address(), cdb_alloc(), classes(), cmd_aea(), cmd_p_minus_e(), cmd_print_bars(), cmd_print_pxA(), compare(), compress_file(), cons_stack_dump(), constant_pool_copy_from_buffer(), context_new(), copy_string_n(), core_analysis_graph_construct_nodes(), core_walk_function_blocks(), create_curl_context(), create_demangler(), create_filename(), create_filename_from_descriptor(), create_filename_from_handle(), create_filename_from_memory(), create_loop(), create_output_name(), create_temp_file(), create_type_name_from_offset(), createCResources(), cursor_create(), dbdiff_cb(), decompress_file(), decompress_file_allocDst(), dem_str_ndup(), dem_string_realloc_no_len_update(), dex_create_relocations(), dex_string_new(), diff_unified_lines_hl(), disasm_until_ret(), do_extract_currentfile(), do_section_search(), do_string_search(), do_syscall_search(), ds_atabs_option(), ds_print_offset(), dump_maps(), echo_read(), ef_read(), encrypt_or_decrypt_block(), ensure_ranged_hint_record(), escape_utf8_for_json(), estimate_slide(), exchange(), extract_binobj(), extract_slice(), file_apprentice(), file_ascmagic(), file_check_mem(), file_mmap(), file_or_fd(), file_vprintf(), fileCheck(), filter_classes(), find_cabinet_file(), find_instruction(), findmust(), flirt_create_child(), foreach_list_cb(), fullSpeedBench(), func_walk_blocks(), function_load_cb(), FUZ_AddressOverflow(), FUZ_createLowAddr(), FUZ_test(), FUZ_unitTests(), FUZZ_dataProducer_create(), fuzzerTests(), gdbr_parse_target_xml(), get_AR_regs_class2(), get_arguments(), get_calls(), get_class_name(), get_class_ro_t(), get_complex_object(), get_data(), get_file_name_from_handle(), get_float_object(), get_ivar_list_t(), get_long_object(), get_method_list_t(), get_namespace_and_name(), get_num(), get_objc_property_list(), get_operator_code(), get_protocol_list_t(), get_rebase_info(), getlistmask(), getpcfromstack(), GetSegmentHeapBlocks(), getstr(), getstring(), GetSystemModules(), go_string(), go_string_from_table(), graph_construct_nodes(), guess_next_autocmplt_token(), gz_error(), gz_init(), gz_look(), gz_open(), gzcopy(), gzdopen(), gzlog_compress(), gzlog_open(), gzscan(), gztack(), hash_parse_hexadecimal(), hash_parse_string(), hash_print_crypto(), header(), hex_string(), hole_new(), info(), init_fi(), init_items(), init_module_runtime_functions(), io_memory_resize(), kd_read_packet(), libdemangle_handler_objc(), list_zip(), LLVMFuzzerTestOneInput(), load(), load_process_final_line(), log_recover(), log_replace(), LZ4_malloc(), LZ4IO_compressFilename_Legacy(), LZ4IO_compressMultipleFilenames(), LZ4IO_compressMultipleFilenames_Legacy(), LZ4IO_createCResources(), LZ4IO_createDict(), LZ4IO_createDResources(), LZ4IO_decodeLegacyStream(), LZ4IO_decompressMultipleFilenames(), LZ4IO_defaultPreferences(), lzma_attribute(), M(), m_alloc(), mach0_info_new(), main(), make_string(), makedir(), matcher(), mem_alloc(), memorise_file(), meta_string_8bit_add(), meta_string_guess_add(), mkdbname(), mpc_and(), mpc_ast_new(), mpc_ast_traverse_next(), mpc_ast_traverse_start(), mpc_check(), mpc_check_with(), mpc_check_withf(), mpc_checkf(), mpc_cleanup(), mpc_copy(), mpc_err_file(), mpc_expect(), mpc_expectf(), mpc_export(), mpc_fail(), mpc_failf(), mpc_input_new_file(), mpc_input_new_nstring(), mpc_input_new_pipe(), mpc_input_new_string(), mpc_malloc(), mpc_noneof(), mpc_oneof(), mpc_or(), mpc_realloc(), mpc_string(), mpca_and(), mpca_or(), mpca_stmt_afold(), mpca_stmt_fold(), mpcf_float(), mpcf_hex(), mpcf_int(), mpcf_oct(), mprint(), msp_alloc(), msp_open(), my_alloc(), new_pyc_opcodes(), next_inst(), nios2_init_opcode_hash(), node_match_functions(), on_new_connection(), on_read(), on_resolved(), pager_splitlines(), parse(), parse_chained_fixups(), parse_ext_opcode(), parse_go_build_info(), parse_symbol_table(), parse_type_arglist(), parse_type_vtshape(), parseDragons(), parseOperand(), path_walker(), pdb7_extract_msf_stream_directory(), pdb7_extract_streams(), Pe_r_bin_pe_parse_string_file_info(), Pe_r_bin_pe_parse_string_table(), Pe_r_bin_pe_parse_var(), Pe_r_bin_pe_parse_var_file_info(), Pe_r_bin_pe_parse_version_info(), perform_mapped_file_yank(), plugin_adler32_small_block(), plugin_entropy_small_block(), plugin_md4_small_block(), plugin_md5_small_block(), plugin_mod255_small_block(), plugin_parity_small_block(), plugin_sha1_small_block(), plugin_sha256_small_block(), plugin_sha384_small_block(), plugin_sha512_small_block(), plugin_xor16_small_block(), plugin_xor8_small_block(), plugin_xxhash32_small_block(), preprocess(), print_cmd_analysis_after_traps_print(), print_format_values(), print_rop(), printCol(), push_attr(), rabin_dump_symbols(), rasm_disasm(), rax(), rcc_fun(), read_elf_intrp(), read_node_bytes(), read_to_memory(), ReadFileMemory(), ReadKernelMemory(), realloc(), reconstruct_chained_fixup(), recover_string_at(), recursive_search_glob(), reg_cache_init(), reopen_in_malloc_cb(), resolve_mig_subsystem(), resolve_syscalls(), roundTripCheck(), rtti_msvc_read_base_class_array(), rtti_msvc_read_type_descriptor(), run_old_command(), rz_alloc_init(), rz_analysis_block_analyze_ops(), rz_analysis_block_update_hash(), rz_analysis_block_was_modified(), rz_analysis_class_base_set_raw(), rz_analysis_class_vtable_set(), rz_analysis_cond_to_string(), rz_analysis_data_new_string(), rz_analysis_diff_fingerprint_bb(), rz_analysis_esil_trace_new(), rz_analysis_function_cost(), rz_analysis_get_delta_jmptbl_info(), rz_analysis_mask(), rz_analyze_bytes_handler(), rz_asm_massemble(), rz_asm_mdisassemble(), rz_asm_mdisassemble_hexstr(), rz_asm_op_set_hexbuf(), rz_asm_pseudo_byte(), rz_asm_pseudo_fill(), rz_asn1_concatenate_strings(), rz_asn1_stringify_bits(), rz_asn1_stringify_bytes(), rz_asn1_stringify_integer(), rz_asn1_stringify_time(), rz_asn1_stringify_utctime(), rz_axml_decode(), rz_base64_encode_dyn(), rz_bin_elf_get_compiler(), rz_bin_fatmach0_init(), rz_bin_mz_init_hdr(), rz_bin_ne_get_imports(), rz_bin_ne_get_symbols(), rz_bin_pdb_omap_remap(), rz_bin_pe_get_entrypoint(), rz_bin_pe_get_exports(), rz_bin_pemixed_init_dos(), rz_bin_te_get_entrypoint(), rz_bin_te_init_hdr(), rz_bin_te_init_sections(), rz_bp_add(), rz_bp_traptrace_add(), rz_buf_fwd_scan(), rz_bv_as_hex_string(), rz_bv_as_string(), rz_cf_value_dict_parse(), rz_cmd(), rz_cmd_alias(), rz_cmd_cmp_file_handler(), rz_cmd_cmp_hex_block_handler(), rz_cmd_cmp_hex_block_hexdiff_handler(), rz_cmd_cmp_hex_diff_lines_handler(), rz_cmd_cmp_hexpair_string_handler(), rz_cmd_disassembly_basic_block_as_text_json_handler(), rz_cmd_disassembly_basic_block_handler(), rz_cmd_disassembly_function_handler(), rz_cmd_help(), rz_cmd_macro_add(), rz_cmd_print(), rz_cmd_search(), rz_cons_canvas_box(), rz_cons_canvas_fill(), rz_cons_canvas_new(), rz_cons_canvas_resize(), rz_cons_column(), rz_cons_fill_line(), rz_cons_flush(), rz_cons_grepbuf(), rz_cons_highlight(), rz_core_analysis_data(), rz_core_analysis_esil(), rz_core_analysis_esil_emulate(), rz_core_analysis_propagate_noreturn(), rz_core_analysis_resolve_golang_strings(), rz_core_analysis_search(), rz_core_analysis_search_xrefs(), rz_core_asm_back_disassemble(), rz_core_asm_back_disassemble_all(), rz_core_asm_bwdisassemble(), rz_core_bin_create_digests(), rz_core_bin_export_info(), rz_core_bin_info_print(), rz_core_cmd_subst_i(), rz_core_cmp_mem_data(), rz_core_cmp_mem_mem(), rz_core_cmpwatch_add(), rz_core_cmpwatch_update(), rz_core_disasm_instruction(), rz_core_disasm_pde(), rz_core_dump(), rz_core_hack_x86(), rz_core_link_stroff(), rz_core_print_disasm(), rz_core_print_disasm_all(), rz_core_print_dump_str(), rz_core_print_function_disasm_json(), rz_core_print_hexdump_byline_str(), rz_core_print_hexdump_diff_str(), rz_core_print_hexdump_or_hexdiff_str(), rz_core_rtr_http_run(), rz_core_search_cb(), rz_core_search_prelude(), rz_core_search_preludes(), rz_core_serve(), rz_core_visual_define(), rz_core_write_base64_at(), rz_core_write_base64d_at(), rz_core_write_hexpair(), rz_core_write_random_at(), rz_core_yank(), rz_coresym_cache_element_new(), rz_crypto_new(), rz_debug_bochs_attach(), rz_debug_dmp_init(), rz_debug_execute(), rz_debug_gdb_map_get(), rz_debug_snap_map(), rz_diff_hex_visual(), rz_diff_levenstein_distance(), rz_diff_myers_distance(), rz_diff_slurp_file(), rz_egg_padding(), rz_egg_raw(), rz_egg_raw_prepend(), rz_file_mkstemp(), rz_file_relpath(), rz_file_slurp(), rz_file_slurp_hexpairs(), rz_file_slurp_range(), rz_flag_set_next(), rz_hash_cfg_calculate_small_block_string(), rz_hash_cfg_final(), rz_hash_cfg_get_result_string(), rz_hash_cfg_hmac(), rz_hash_cfg_init(), rz_heap_blocks_list(), rz_hex_bin2strdup(), rz_hex_from_c(), rz_hex_from_js(), rz_hex_from_py(), rz_io_set_write_mask(), rz_is_heap(), rz_kext_index_new(), rz_lib_path(), rz_magic_new(), rz_main_rz_agent(), rz_main_rz_bin(), rz_main_rz_gg(), rz_mem_cmp_mask(), rz_mem_dup(), rz_new_copy(), rz_num_dup(), rz_num_math(), rz_num_tail(), rz_num_tailff(), rz_num_units(), rz_pkcs7_parse_digestalgorithmidentifier(), rz_print_json_human(), rz_print_json_indent(), rz_range_add_from_string(), rz_range_set_data(), rz_rap_packet(), rz_reg_arena_dup(), rz_reg_arena_peek(), rz_reg_arena_set_bytes(), rz_reg_arenas_write_hex_handler(), rz_reg_get_bvalue(), rz_reg_get_bytes(), rz_search_deltakey_update(), rz_search_keyword_new(), rz_search_keyword_new_hex(), rz_search_keyword_new_hexmask(), rz_search_keyword_new_regexp(), rz_search_keyword_new_str(), rz_search_keyword_new_wide(), rz_search_mybinparse_update(), rz_sign_flirt_node_new(), rz_sign_flirt_parse_compressed_pattern_from_buffer(), rz_sign_flirt_parse_header_compressed_pattern_from_buffer(), rz_socket_http_accept(), rz_socket_http_handle_upload(), rz_socket_rap_client_command(), rz_socket_rap_client_open(), rz_socket_rap_client_write(), rz_socket_slurp(), rz_socket_to_string(), rz_stdin_slurp(), rz_str_ansi_crop(), rz_str_ansi_filter(), rz_str_arg_escape(), rz_str_argv(), rz_str_escape_(), rz_str_escape_sh(), rz_str_escape_utf(), rz_str_home(), rz_str_ndup(), rz_str_newlen(), rz_str_path_escape(), rz_str_prefix_all(), rz_str_sanitize_sdb_key(), rz_str_uri_encode(), rz_str_utf16_encode(), rz_str_word_get0set(), rz_strbuf_append(), rz_strbuf_append_n(), rz_strbuf_copy(), rz_strbuf_prepend(), rz_strbuf_set(), rz_strbuf_setbin(), rz_strbuf_vappendf(), rz_strbuf_vsetf(), rz_strpool_new(), rz_strpool_slice(), rz_sys_getenv(), rz_sys_pid_to_path(), rz_sys_run(), rz_sys_run_rop(), rz_table_columns(), rz_test_load_asm_test_file(), rz_test_run_asm_test(), rz_th_sem_new(), rz_type_format_time(), rz_x509_parse_crl(), rz_x509_parse_crlentry(), rzpipe_cmdf(), rzpipe_write(), sdb_array_add_sorted(), sdb_array_append(), sdb_array_get(), sdb_array_insert(), sdb_array_prepend(), sdb_array_set(), sdb_array_sort_num(), sdb_concat(), sdb_disk_create(), sdb_dump_dupnext(), sdb_fmt_array(), sdb_fmt_array_num(), sdb_itoa(), sdb_journal_load(), sdb_new(), sdb_ns_new(), sdb_querys(), sdb_set_internal(), sdbkv_new2(), search_hash(), set_mod_inf(), slurp(), socket_http_answer(), source_nul(), sp_open(), srecord_parse(), stdin_gets(), strbuf_rev_append_char(), strbuf_rev_prepend_char(), strcat_dup(), strdup_limit(), strdupn(), string_init(), TAG_CALLBACK(), test_code(), test_compress(), test_corrupt(), test_decompress(), test_lz4f_decompression(), test_lz4f_decompression_wBuffers(), trad_pkware_new(), ts_malloc_default(), type_code_str_get(), unzRepair(), update(), update_varz_analysisysis(), utf16_allocate_tempname(), utf16be_to_utf8(), UTIL_createFileList(), vector_clone(), vector_quick_sort(), w32_desc_list(), w32_info_user(), w32_list_heaps_blocks(), win32_build_iowin(), windbg_map_get(), windbg_modules_get(), window_from_handle(), winkd_write_reg(), winzip_aes_new(), write_data(), write_memory_src_to_file(), WriteKernelMemory(), xnu_get_pid(), xor_init_state(), xtensa_insnbuf_alloc(), XXH_malloc(), zcalloc(), zip_close(), zip_dir_add(), zip_error_strerror(), zip_register_progress_callback(), zip_secure_random(), zip_source_buffer_fragment_with_attributes_create(), zip_source_crc_create(), zip_source_file_common_new(), and zip_source_file_create().

◆ realloc()

void* realloc ( void *  ptr,
size_t  size 
)

Definition at line 144 of file malloc.c.

144  {
145  void *ret;
146 
147  if (!inited) {
148  init();
149  }
150 
151  if (size >= min_size && count >= max_count) {
152  errno = ENOMEM;
153  return NULL;
154  }
155 
156  ret = real_realloc(ptr, size);
157  if (size >= min_size) {
158  count++;
159  }
160 
161  return ret;
162 }

References count, ENOMEM, init(), inited, max_count, min_size, NULL, and real_realloc.

Referenced by __add_menu(), __desc_cache_list_cb(), __expandLine(), _zip_add_entry(), _zip_cdir_grow(), _zip_register_source(), addpoint(), allocset(), append(), been_here(), bin_pe_init_imports(), bin_pe_init_security(), bin_pe_parse_imports(), block_load_cb(), buf_bytes_resize(), buf_sparse_resize(), buffer_grow_fragments(), buffer_write(), build(), copy_string_n(), core_analysis_graph_label(), d_growable_string_resize(), deflate_index_build(), dem_str_append(), dem_str_replace(), dem_string_realloc_no_len_update(), enlarge(), expand_abbrev_decl(), expand_cu(), expand_debug_abbrev(), expand_info(), file_check_mem(), file_getbuffer(), function_load_cb(), gdbr_parse_target_xml(), gdbr_read_feature(), gdbr_read_osdata(), get_arguments(), id_storage_reallocate(), InitHeapInfo(), lbuf_strcat(), like_cb(), load(), main(), mcadd(), mpc_ast_add_child(), mpc_ast_add_root_tag(), mpc_ast_add_tag(), mpc_ast_tag(), mpc_err_string(), mpc_expectf(), mpc_failf(), mpc_input_mark(), mpc_input_success(), mpc_input_unmark(), mpc_new(), mpc_optimise_unretained(), mpc_realloc(), mpca_grammar_find_parser(), mpcf_escape_new(), mpcf_re_range(), mpcf_strfold(), mpcf_unescape_new(), next_append(), oid_storage_preallocate(), pager_splitlines(), palloc(), parse(), parse_dylib(), parse_segments(), parse_symbol_table(), Pe_r_bin_pe_parse_string(), Pe_r_bin_pe_parse_string_file_info(), Pe_r_bin_pe_parse_string_table(), Pe_r_bin_pe_parse_var_file_info(), read_ahead(), read_unwind_info(), rz_alloc_init(), rz_analysis_block_set_op_offset(), rz_analysis_diff_fingerprint_fcn(), rz_asm_massemble(), rz_bin_pe_check_sections(), rz_bin_pe_get_imports(), rz_bin_pe_get_libs(), rz_bp_item_insert(), rz_cmd_alias_set(), rz_cmd_parsed_args_addarg(), rz_cons_canvas_resize(), rz_cons_readpush(), rz_core_add_asmqjmp(), rz_core_autocomplete_add(), rz_core_autocomplete_remove(), rz_core_block_size(), rz_core_print_disasm(), rz_crypto_append(), rz_debug_gdb_reg_read(), rz_debug_gdb_reg_write(), rz_debug_qnx_reg_read(), rz_debug_qnx_reg_write(), rz_diff_resize_buffer(), rz_file_slurp(), rz_print_json_human(), rz_print_json_indent(), rz_print_set_rowoff(), rz_reg_fit_arena(), rz_reg_get_bytes(), rz_reg_set_bytes(), rz_socket_slurp(), rz_stack_push(), rz_stdin_slurp(), rz_str_append(), rz_str_arg_escape(), rz_str_argv(), rz_str_path_escape(), rz_str_prepend(), rz_str_replace(), rz_str_replace_icase(), rz_str_replace_thunked(), rz_str_uri_encode(), rz_str_utf16_encode(), rz_strbuf_append(), rz_strbuf_append_n(), rz_strbuf_reserve(), rz_strpool_alloc(), rz_strpool_fit(), rz_sys_getenv(), rz_uleb128_encode(), rzpipe_read(), slurp(), sparse_write(), strbuf_append(), string_printf(), stripsnug(), TAG_CALLBACK(), ts_realloc_default(), UTIL_realloc(), w32_desc_list(), windbg_open(), winkd_read_reg(), and xrealloc().

Variable Documentation

◆ count

size_t count = 0
static

Definition at line 66 of file malloc.c.

Referenced by calloc(), malloc(), and realloc().

◆ inited

int inited = 0
static

Definition at line 65 of file malloc.c.

Referenced by calloc(), init(), malloc(), and realloc().

◆ max_count

◆ min_size

size_t min_size = 0
static

Definition at line 68 of file malloc.c.

Referenced by calloc(), init(), malloc(), realloc(), and rz_heap_chunks_list().

◆ myname

const char* myname = NULL
static

Definition at line 73 of file malloc.c.

Referenced by init().

◆ real_calloc

void*(* real_calloc) (size_t number, size_t size) ( size_t  number,
size_t  size 
) = NULL
static

Definition at line 70 of file malloc.c.

Referenced by calloc(), and init().

◆ real_malloc

void*(* real_malloc) (size_t size) ( size_t  size) = NULL
static

Definition at line 69 of file malloc.c.

Referenced by init(), and malloc().

◆ real_realloc

void*(* real_realloc) (void *ptr, size_t size) ( void *  ptr,
size_t  size 
) = NULL
static

Definition at line 71 of file malloc.c.

Referenced by init(), and realloc().