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.
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.
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
Enumerator:
MEM_POISON_ALLOC 
MEM_POISON_FREE 

Function Documentation

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, 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().

void mem_free ( void p)

References mem_flags, MEM_POISON_FREE, and SZ.

Referenced by _find_in_range(), build_color_point(), call_monster(), cave_free(), cave_generate(), cavern_chunk(), chest_death(), classic_gen(), clean_specs(), cleanup_act(), cleanup_angband(), cleanup_artifact(), cleanup_body(), cleanup_class(), cleanup_cmds(), cleanup_constants(), cleanup_ego(), cleanup_feat(), cleanup_flavor(), cleanup_hints(), cleanup_history(), cleanup_ignore(), cleanup_lore(), cleanup_mon_base(), cleanup_mon_spell(), cleanup_monster(), cleanup_names(), cleanup_obj_make(), cleanup_object(), cleanup_object_base(), cleanup_p_race(), cleanup_pain(), cleanup_pits(), cleanup_player(), cleanup_profile(), cleanup_quest(), cleanup_race_allocs(), cleanup_room(), cleanup_stores(), cleanup_trap(), cleanup_v(), clear_small_regions(), close_graphics_modes(), connect_caverns(), create_slay_cache(), describe_damage(), dice_free(), display_knowledge(), display_map(), do_cmd_knowledge_artifacts(), do_cmd_knowledge_ego_items(), do_cmd_knowledge_features(), do_cmd_knowledge_monsters(), do_cmd_query_symbol(), do_randart(), effect_handler_WONDER(), ego_menu(), ensure_connectedness(), eval_monster_power(), event_remove_all_handlers(), event_remove_handler(), expression_copy(), expression_free(), expression_new(), file_close(), file_open(), finish_parse_act(), finish_parse_artifact(), finish_parse_body(), finish_parse_ego(), finish_parse_feat(), finish_parse_grafmode(), finish_parse_monster(), finish_parse_names(), finish_parse_object(), finish_parse_object_base(), finish_parse_pain(), finish_parse_pit(), finish_parse_profile(), finish_parse_quest(), finish_parse_trap(), flags_mask(), flatten_stores(), free_birth_menu(), free_brand(), free_effect(), free_slay(), free_slay_cache(), history_clear(), ignore_collect_kind(), init_obj_make(), init_race_allocs(), item_is_available(), join_region(), keymap_free(), keymap_remove(), labyrinth_chunk(), load_block(), menu_dynamic_free(), message_add(), messages_free(), modified_chunk(), mon_create_drop(), monmsg_cleanup(), monster_list_free(), monster_list_new(), moria_chunk(), mutate_cavern(), my_dclose(), object_delete(), object_list_free(), object_list_new(), option_toggle_menu(), panel_free(), parse_artifact_flags(), parse_artifact_values(), parse_body_slot(), parse_class_equip(), parse_class_flags(), parse_ego_flags(), parse_ego_min_val(), parse_ego_values(), parse_feat_flags(), parse_lore_f(), parse_lore_s(), 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(), parser_destroy(), parser_freeold(), parser_parse(), parser_reg(), player_init(), player_pickup_item(), player_quests_free(), player_spells_free(), point_set_dispose(), process_pref_file_command(), process_pref_file_layered(), quarks_free(), ranged_helper(), rd_traps_aux(), remove_trap_aux(), scan_items(), see_floor_items(), set_free(), slay_power(), spell_cast(), spell_menu_destroy(), spell_menu_new(), spoil_mon_desc(), spoil_mon_info(), square_free_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(), textblock_free(), textblock_to_file(), textblock_vappend_c(), textui_browse_object_knowledge(), textui_enter_store(), textui_get_item(), textui_prefs_free(), textui_store_knowledge(), textui_textblock_place(), textui_textblock_show(), try_save(), vformat_kill(), wipe_brands(), wipe_monster_lore(), wipe_slays(), wiz_reroll_item(), wr_objects_aux(), wr_traps_aux(), and write_html_escape_char().

void* mem_realloc ( void p,
size_t  len 
)
void* mem_zalloc ( size_t  len)

References mem_alloc().

Referenced by append_random_brand(), append_random_slay(), brand_collect(), build_color_point(), call_monster(), cave_generate(), cave_new(), cavern_chunk(), chunk_list_add(), classic_gen(), clear_small_regions(), connect_caverns(), copy_brand(), copy_slay(), create_slay_cache(), dice_add_variable(), dice_new(), display_knowledge(), display_map(), do_cmd_buy(), do_cmd_knowledge_artifacts(), do_cmd_knowledge_ego_items(), do_cmd_knowledge_features(), do_cmd_knowledge_monsters(), do_cmd_query_symbol(), do_randart(), effect_handler_BIZARRE(), effect_handler_WONDER(), effect_simple(), ego_menu(), ensure_connectedness(), eval_monster_power(), expression_copy(), expression_new(), file_open(), finish_parse_act(), finish_parse_artifact(), finish_parse_body(), finish_parse_ego(), finish_parse_feat(), finish_parse_grafmode(), finish_parse_monster(), finish_parse_names(), finish_parse_object(), finish_parse_object_base(), finish_parse_pain(), finish_parse_pit(), finish_parse_profile(), finish_parse_quest(), finish_parse_trap(), flags_mask(), flatten_stores(), history_init(), init_ignore(), init_obj_make(), init_parse_constants(), init_parse_names(), init_parse_object_base(), init_parse_prefs(), init_player(), init_race_allocs(), item_is_available(), join_region(), keymap_add(), keymap_make(), labyrinth_chunk(), make_gold(), menu_dynamic_add_valid(), message_add(), message_color_define(), messages_init(), modified_chunk(), mon_create_drop(), monmsg_init(), monster_list_new(), moria_chunk(), mutate_cavern(), my_dopen(), obj_known_damage(), object_list_new(), object_new(), panel_allocate(), parse_act_effect(), parse_act_name(), parse_always(), parse_artifact_name(), parse_artifact_values(), parse_body_body(), parse_body_slot(), parse_buy(), parse_buy_flag(), parse_class_book(), parse_class_effect(), parse_class_equip(), parse_class_magic(), parse_class_name(), parse_ego_effect(), parse_ego_item(), parse_ego_name(), parse_ego_type(), parse_ego_values(), parse_feat_name(), parse_flavor_flavor(), parse_graf_n(), parse_hint(), parse_history_chart(), parse_lore_drop(), parse_lore_drop_artifact(), parse_lore_friends(), parse_lore_friends_base(), parse_lore_mimic(), parse_mon_base_name(), parse_mon_spell_effect(), parse_mon_spell_name(), parse_monster_blow(), parse_monster_drop(), parse_monster_drop_artifact(), parse_monster_friends(), parse_monster_friends_base(), parse_monster_mimic(), parse_monster_name(), parse_names_word(), parse_normal(), parse_object_effect(), parse_object_name(), parse_object_values(), 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_quest_name(), parse_room_n(), parse_trap_effect(), parse_trap_name(), parse_v_n(), parser_new(), place_trap(), player_init(), player_outfit(), player_pickup_item(), player_quests_reset(), player_spells_init(), point_set_new(), quarks_init(), rd_item(), rd_player(), rd_traps_aux(), scan_items(), see_floor_items(), set_new(), setup_tests(), slay_collect(), slay_power(), spell_cast(), spell_collect_from_book(), spell_identify_unknown_available(), 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(), and wr_traps_aux().

char* string_append ( char *  s1,
const char *  s2 
)
void string_free ( char *  str)
char* string_make ( const char *  str)

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

References mem_alloc(), and my_strcpy().

Referenced by append_random_brand(), append_random_slay(), artifact_gen_name(), brand_collect(), cave_generate(), 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(), copy_brand(), copy_slay(), de_armour(), default_layout_win(), dice_add_variable(), do_cmd_choose_history(), expression_add_operations_string(), file_open(), grab_base_and_int(), init_file_paths(), init_names(), init_obj_make(), menu_dynamic_add_valid(), message_add(), my_dopen(), parse_act_name(), parse_artifact_flags(), parse_artifact_name(), parse_artifact_values(), parse_body_body(), parse_body_slot(), parse_buy_flag(), parse_class_flags(), parse_class_name(), parse_class_spell(), parse_class_title(), parse_ego_flags(), parse_ego_min_val(), parse_ego_name(), parse_ego_values(), parse_feat_flags(), parse_feat_name(), parse_hint(), parse_lore_f(), parse_lore_friends(), parse_lore_s(), 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_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_quest_name(), parse_room_n(), parse_specs(), parse_store(), parse_trap_flags(), parse_trap_name(), parse_v_n(), parser_parse(), parser_reg(), player_outfit(), player_quests_reset(), quark_add(), rd_dungeon_aux(), rd_item(), rd_player(), slay_collect(), string_append(), test_string_append(), test_string_append_null1(), test_string_make(), test_string_make_null(), and write_dummy_object_record().

Variable Documentation

unsigned int mem_flags

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