Angband
Enumerations | Functions | Variables
z-virt.h File Reference

Memory management. More...

#include "h-basic.h"

Go to the source code of this file.

Enumerations

enum  { MEM_POISON_ALLOC = 0x00000001, MEM_POISON_FREE = 0x00000002 }
 

Functions

voidmem_alloc (size_t len)
 Replacements for malloc() and friends that die on failure. More...
 
voidmem_zalloc (size_t len)
 
void mem_free (void *p)
 
voidmem_realloc (void *p, size_t len)
 
char * string_make (const char *str)
 Duplicates an existing string str, allocating as much memory as necessary. More...
 
void string_free (char *str)
 
char * string_append (char *s1, const char *s2)
 

Variables

unsigned int mem_flags
 

Detailed Description

Memory management.

Copyright (c) 1997 Ben Harrison

This software may be copied and distributed for educational, research, and not for profit purposes provided that this copyright and statement are included in all such copies.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
MEM_POISON_ALLOC 
MEM_POISON_FREE 

Function Documentation

◆ mem_alloc()

void* mem_alloc ( size_t  len)

Replacements for malloc() and friends that die on failure.

Replacements for malloc() and friends that die on failure.

Returns:

  • NULL if len == 0; or
  • a pointer to a block of memory of at least len bytes

Doesn't return on out of memory.

References mem_flags, MEM_POISON_ALLOC, NULL, quit(), and SZ.

Referenced by _find_in_range(), event_add_handler(), finish_parse_names(), ignore_collect_kind(), init_birth_menu(), load_block(), make_ranged_shot(), make_ranged_throw(), mem_zalloc(), menu_new(), parse_object_base_name(), parse_specs(), parser_parse(), parser_reg(), point_set_new(), spell_menu_new(), stats_db_open(), stats_make_output_dir(), string_make(), test_alloc(), try_save(), and write_html_escape_char().

◆ mem_free()

void mem_free ( void p)

References mem_flags, MEM_POISON_FREE, and SZ.

Referenced by _find_in_range(), alloc_init_egos(), artifact_prep(), artifact_set_data_free(), build_color_point(), calc_inventory(), call_monster(), cave_free(), cave_generate(), cavern_chunk(), check_artifact_curses(), check_object_curses(), classic_gen(), clean_specs(), cleanup_act(), cleanup_angband(), cleanup_artifact(), cleanup_body(), cleanup_brand(), cleanup_class(), cleanup_cmds(), cleanup_constants(), cleanup_curse(), cleanup_eff(), cleanup_ego(), cleanup_feat(), cleanup_flavor(), cleanup_hints(), cleanup_history(), cleanup_ignore(), cleanup_lore(), cleanup_meth(), cleanup_mon_base(), cleanup_mon_spell(), cleanup_monster(), cleanup_names(), cleanup_obj_make(), cleanup_object(), cleanup_object_base(), cleanup_object_power(), cleanup_object_property(), cleanup_p_race(), cleanup_pain(), cleanup_pits(), cleanup_player(), cleanup_profile(), cleanup_projection(), cleanup_quest(), cleanup_race_allocs(), cleanup_realm(), cleanup_room(), cleanup_rune(), cleanup_slay(), cleanup_stores(), cleanup_trap(), cleanup_vault(), cleanup_world(), clear_small_regions(), close_audio(), close_graphics_modes(), connect_caverns(), copy_artifact(), create_artifact_set(), curse_menu(), describe_damage(), design_artifact(), dice_free(), dir_create(), display_knowledge(), display_map(), do_cmd_knowledge_artifacts(), do_cmd_knowledge_ego_items(), do_cmd_knowledge_features(), do_cmd_knowledge_monsters(), do_cmd_knowledge_runes(), do_cmd_knowledge_traps(), do_cmd_query_symbol(), do_cmd_wiz_cure_all(), effect_handler_TELEPORT(), ego_menu(), ensure_connectedness(), event_remove_all_handlers(), event_remove_handler(), event_remove_handler_type(), expression_copy(), expression_free(), expression_new(), file_close(), file_open(), finish_parse_act(), finish_parse_artifact(), finish_parse_body(), finish_parse_brand(), finish_parse_curse(), finish_parse_eff(), finish_parse_ego(), finish_parse_feat(), finish_parse_grafmode(), finish_parse_meth(), finish_parse_monster(), finish_parse_names(), finish_parse_object(), finish_parse_object_base(), finish_parse_object_power(), finish_parse_object_property(), finish_parse_pain(), finish_parse_pit(), finish_parse_profile(), finish_parse_projection(), finish_parse_quest(), finish_parse_randart(), finish_parse_slay(), finish_parse_trap(), flags_mask(), flatten_stores(), free_birth_menu(), free_effect(), history_clear(), ignore_collect_kind(), init_money_svals(), init_race_allocs(), item_menu(), join_region(), keymap_free(), keymap_remove(), labyrinth_chunk(), load_block(), load_sound(), load_sound_sdl(), menu_dynamic_free(), menu_free(), message_add(), messages_free(), modified_chunk(), mon_create_drop(), monster_list_free(), monster_list_new(), moria_chunk(), mutate_cavern(), my_dclose(), obj_known_damage(), object_find_unknown_rune(), object_free(), object_list_free(), object_list_new(), object_power(), object_wipe(), option_toggle_menu(), panel_free(), parse_artifact_flags(), parse_artifact_values(), parse_body_slot(), parse_class_equip(), parse_class_flags(), parse_curse_conflict_flags(), parse_curse_flags(), parse_curse_values(), parse_ego_flags(), parse_ego_flags_off(), parse_ego_min_val(), parse_ego_values(), parse_feat_flags(), parse_lore_flags(), parse_lore_spells(), parse_mon_base_flags(), parse_mon_base_spells(), parse_monster_flags(), parse_monster_flags_off(), parse_monster_spells(), parse_object_base_flags(), parse_object_flags(), parse_object_values(), parse_p_race_obj_flags(), parse_p_race_play_flags(), parse_p_race_values(), parse_pit_flags_ban(), parse_pit_flags_req(), parse_pit_spell_ban(), parse_pit_spell_req(), parse_trap_flags(), parse_trap_save_flags(), parser_destroy(), parser_freeold(), parser_parse(), parser_reg(), pick_trap(), player_book_has_unlearned_spells(), player_init(), player_pickup_item(), player_quests_free(), player_spells_free(), point_set_dispose(), process_pref_file_command(), process_pref_file_named(), quarks_free(), ranged_helper(), rd_traps_aux(), remove_object_curse(), scan_items(), see_floor_items(), set_free(), spell_cast(), spell_menu_destroy(), spell_menu_new(), spoil_mon_desc(), spoil_mon_info(), square_free_trap(), square_remove_all_traps(), square_remove_trap(), stats_db_close(), store_base_power(), string_free(), sval_menu(), target_set_interactive(), target_set_interactive_aux(), teardown_tests(), Term_load(), term_nuke(), Term_resize(), term_win_nuke(), test_alloc(), test_names(), test_realloc(), test_word0(), test_word1(), textblock_free(), textblock_to_file(), textblock_vappend_c(), textui_browse_object_knowledge(), textui_get_item(), textui_prefs_free(), textui_store_knowledge(), textui_textblock_place(), textui_textblock_show(), try_save(), unload_sound_sdl(), use_store(), vformat_kill(), wipe_monster_lore(), wiz_reroll_item(), wr_objects_aux(), wr_traps_aux(), write_character_dump(), and write_html_escape_char().

◆ mem_realloc()

void* mem_realloc ( void p,
size_t  len 
)

◆ mem_zalloc()

void* mem_zalloc ( size_t  len)

References mem_alloc().

Referenced by alloc_init_egos(), alloc_init_objects(), append_artifact_curse(), append_object_curse(), append_random_brand(), append_random_slay(), artifact_set_data_new(), build_color_point(), calc_inventory(), call_monster(), cave_generate(), cave_new(), cavern_chunk(), chunk_list_add(), classic_gen(), clear_small_regions(), connect_caverns(), copy_artifact(), copy_brands(), copy_curses(), copy_slays(), create_artifact_set(), curse_menu(), describe_damage(), design_artifact(), dice_add_variable(), dice_new(), dir_create(), display_knowledge(), display_map(), do_cmd_knowledge_artifacts(), do_cmd_knowledge_ego_items(), do_cmd_knowledge_features(), do_cmd_knowledge_monsters(), do_cmd_knowledge_runes(), do_cmd_knowledge_traps(), do_cmd_query_symbol(), effect_handler_TELEPORT(), ego_menu(), ensure_connectedness(), expression_copy(), expression_new(), file_open(), finish_parse_act(), finish_parse_artifact(), finish_parse_body(), finish_parse_brand(), finish_parse_curse(), finish_parse_eff(), finish_parse_ego(), finish_parse_feat(), finish_parse_grafmode(), finish_parse_meth(), finish_parse_monster(), finish_parse_names(), finish_parse_object(), finish_parse_object_base(), finish_parse_object_power(), finish_parse_object_property(), finish_parse_pain(), finish_parse_pit(), finish_parse_profile(), finish_parse_projection(), finish_parse_quest(), finish_parse_randart(), finish_parse_slay(), finish_parse_trap(), flags_mask(), flatten_stores(), get_join_info(), grow_sound_list(), history_init(), init_ignore(), init_money_svals(), init_parse_constants(), init_parse_names(), init_parse_object_base(), init_parse_prefs(), init_player(), init_race_allocs(), init_rune(), item_menu(), join_region(), keymap_add(), keymap_make(), labyrinth_chunk(), load_sound(), load_sound_sdl(), make_gold(), menu_dynamic_add_valid(), message_add(), message_color_define(), messages_init(), modified_chunk(), mon_create_drop(), monster_list_new(), moria_chunk(), mutate_cavern(), my_dopen(), obj_known_damage(), object_copy(), object_find_unknown_rune(), object_list_new(), object_new(), object_power(), panel_allocate(), parse_act_effect(), parse_act_name(), parse_always(), parse_artifact_brand(), parse_artifact_curse(), parse_artifact_name(), parse_artifact_slay(), parse_body_body(), parse_body_slot(), parse_brand_code(), parse_buy(), parse_buy_flag(), parse_class_book(), parse_class_effect(), parse_class_equip(), parse_class_magic(), parse_class_name(), parse_curse_effect(), parse_curse_name(), parse_eff_name(), parse_ego_brand(), parse_ego_curse(), parse_ego_effect(), parse_ego_item(), parse_ego_name(), parse_ego_slay(), parse_ego_type(), parse_feat_name(), parse_flavor_flavor(), parse_graf_name(), parse_hint(), parse_history_chart(), parse_lore_drop(), parse_lore_friends(), parse_lore_friends_base(), parse_lore_mimic(), parse_meth_name(), parse_mon_base_name(), parse_mon_spell_effect(), parse_mon_spell_name(), parse_monster_blow(), parse_monster_drop(), parse_monster_friends(), parse_monster_friends_base(), parse_monster_mimic(), parse_monster_name(), parse_names_word(), parse_normal(), parse_object_brand(), parse_object_curse(), parse_object_effect(), parse_object_name(), parse_object_power_item(), parse_object_power_name(), parse_object_power_type(), parse_object_property_name(), parse_object_slay(), parse_owner(), parse_p_race_name(), parse_pain_type(), parse_pit_color(), parse_pit_mon_ban(), parse_pit_mon_base(), parse_pit_name(), parse_profile_name(), parse_profile_room(), parse_projection_code(), parse_quest_name(), parse_realm_name(), parse_room_name(), parse_slay_code(), parse_trap_effect(), parse_trap_effect_xtra(), parse_trap_name(), parse_vault_name(), parse_world_level(), parser_new(), pick_trap(), place_trap(), player_book_has_unlearned_spells(), player_embody(), player_init(), player_know_object(), player_pickup_item(), player_quests_reset(), player_spells_init(), point_set_new(), quarks_init(), rd_dungeon_aux(), rd_item(), rd_player(), rd_traps_aux(), scan_items(), see_floor_items(), set_new(), setup_tests(), spell_cast(), spell_collect_from_book(), spoil_mon_desc(), spoil_mon_info(), store_base_power(), store_menu_init(), store_new(), target_set_interactive(), target_set_interactive_aux(), term_init(), Term_resize(), Term_save(), term_win_init(), textblock_new(), textblock_vappend_c(), textui_browse_object_knowledge(), textui_get_item(), textui_knowledge_init(), textui_prefs_init(), vformat(), wiz_reroll_item(), wr_objects_aux(), wr_traps_aux(), and write_character_dump().

◆ string_append()

char* string_append ( char *  s1,
const char *  s2 
)

◆ string_free()

void string_free ( char *  str)

References mem_free().

Referenced by cave_free(), cave_store(), change_path(), cleanup_act(), cleanup_angband(), cleanup_artifact(), cleanup_body(), cleanup_brand(), cleanup_class(), cleanup_curse(), cleanup_eff(), cleanup_ego(), cleanup_feat(), cleanup_hints(), cleanup_meth(), cleanup_mon_base(), cleanup_mon_spell(), cleanup_monster(), cleanup_names(), cleanup_obj_make(), cleanup_object(), cleanup_object_base(), cleanup_object_power(), cleanup_object_property(), cleanup_p_race(), cleanup_pain(), cleanup_pits(), cleanup_player(), cleanup_player_timed(), cleanup_profile(), cleanup_projection(), cleanup_quest(), cleanup_realm(), cleanup_slay(), cleanup_stores(), cleanup_trap(), cleanup_world(), close_audio(), context_menu_cave(), context_menu_object(), context_menu_player(), context_menu_player_2(), context_menu_store(), context_menu_store_item(), default_layout_win(), describe_artifact(), design_artifact(), dice_reset(), do_cmd_choose_history(), do_cmd_choose_name(), do_cmd_roll_stats(), expression_add_operations_string(), feat_lore(), finish_parse_lore(), finish_parse_monster(), init_arrays(), init_file_paths(), menu_dynamic_free(), message_sound_define(), parse_artifact_curse(), parse_prefs_expr(), parse_prefs_gf(), parse_trap_visibility(), player_quests_free(), quarks_free(), rune_lore(), teardown_tests(), test_0(), test_string_append(), test_string_append_null0(), test_string_append_null1(), test_string_free_null(), test_string_make(), test_word0(), test_word1(), trap_lore(), and tval_find_idx().

◆ string_make()

char* string_make ( const char *  str)

Duplicates an existing string str, allocating as much memory as necessary.

References mem_alloc(), my_strcpy(), and NULL.

Referenced by artifact_gen_name(), cave_store(), change_path(), cmd_set_arg_string(), context_menu_cave(), context_menu_object(), context_menu_player(), context_menu_player_2(), context_menu_store(), context_menu_store_item(), de_armour(), default_layout_win(), describe_artifact(), dice_add_variable(), dir_create(), do_cmd_choose_history(), expression_add_operations_string(), feat_lore(), file_open(), grab_base_and_int(), init_arrays(), init_file_paths(), init_money_svals(), menu_dynamic_add_valid(), message_add(), message_sound_define(), my_dopen(), parse_act_name(), parse_artifact_curse(), parse_artifact_flags(), parse_artifact_name(), parse_artifact_values(), parse_body_body(), parse_body_slot(), parse_brand_code(), parse_brand_name(), parse_brand_verb(), parse_class_flags(), parse_class_name(), parse_class_spell(), parse_class_title(), parse_curse_conflict_flags(), parse_curse_flags(), parse_curse_name(), parse_curse_values(), parse_eff_effect_type(), parse_eff_name(), parse_ego_curse(), parse_ego_flags(), parse_ego_flags_off(), parse_ego_min_val(), parse_ego_name(), parse_ego_values(), parse_feat_flags(), parse_feat_mimic(), parse_feat_name(), parse_hint(), parse_lore_flags(), parse_lore_friends(), parse_lore_spells(), parse_meth_name(), parse_mon_base_flags(), parse_mon_base_name(), parse_mon_base_spells(), parse_monster_flags(), parse_monster_flags_off(), parse_monster_friends(), parse_monster_name(), parse_monster_plural(), parse_monster_spells(), parse_names_word(), parse_object_base_flags(), parse_object_base_name(), parse_object_flags(), parse_object_name(), parse_object_power_apply_to(), parse_object_power_name(), parse_object_property_adjective(), parse_object_property_desc(), parse_object_property_msg(), parse_object_property_name(), parse_object_property_neg_adj(), parse_object_values(), parse_owner(), parse_p_race_name(), parse_p_race_obj_flags(), parse_p_race_play_flags(), parse_p_race_values(), parse_pain_message(), parse_pit_flags_ban(), parse_pit_flags_req(), parse_pit_name(), parse_pit_spell_ban(), parse_pit_spell_req(), parse_prefs_expr(), parse_prefs_gf(), parse_profile_name(), parse_profile_room(), parse_projection_blind_desc(), parse_projection_desc(), parse_projection_name(), parse_projection_player_desc(), parse_projection_type(), parse_quest_name(), parse_realm_book_noun(), parse_realm_name(), parse_realm_spell_noun(), parse_realm_verb(), parse_room_name(), parse_slay_base(), parse_slay_code(), parse_slay_melee_verb(), parse_slay_name(), parse_slay_range_verb(), parse_specs(), parse_store(), parse_trap_flags(), parse_trap_name(), parse_trap_save_flags(), parse_trap_visibility(), parse_vault_name(), parse_vault_type(), parse_world_level(), parser_parse(), parser_reg(), player_embody(), player_quests_reset(), quark_add(), rd_chunks(), rd_dungeon_aux(), rd_player(), rune_lore(), string_append(), test_string_append(), test_string_append_null1(), test_string_make(), test_string_make_null(), trap_lore(), and write_dummy_object_record().

Variable Documentation

◆ mem_flags

unsigned int mem_flags

Referenced by debug_opt(), mem_alloc(), and mem_free().