Changeset 346

Show
Ignore:
Timestamp:
07/14/07 15:13:28 (1 year ago)
Author:
takkaria
Message:

Review and alter memory handling:

  • No-one ever needs to worry about OOM conditions now. (Though OOM should probably trigger a panic save, using a lifeboat a la the Mac port).
  • Add a realloc hook, rename things a bit
  • Ensure correct hooks set by using an API function to do it
  • string_make() no longer is const; I believe Angband now always means "const" when it says "const"
  • memory macros that assign to one of their parameters are removed
  • FREE() always sets its argument to NULL
  • remove C_BSET() and C_SET()
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/cave.c

    r310 r346  
    24922492 
    24932493        /* Make hack */ 
    2494         MAKE(hack, vinfo_hack); 
     2494        hack = ZNEW(vinfo_hack); 
    24952495 
    24962496 
     
    26832683 
    26842684        /* Kill hack */ 
    2685         KILL(hack); 
     2685        FREE(hack); 
    26862686 
    26872687 
  • trunk/src/cmd1.c

    r305 r346  
    507507        int sound_msg; 
    508508 
    509         /* Allocate and wipe an array of ordinary gold objects */ 
    510         C_MAKE(treasure, SV_GOLD_MAX, byte); 
    511         (void)C_WIPE(treasure, SV_GOLD_MAX, byte); 
     509        /* Allocate an array of ordinary gold objects */ 
     510        treasure = C_ZNEW(SV_GOLD_MAX, byte); 
     511 
    512512 
    513513        /* Pick up all the ordinary gold objects */ 
  • trunk/src/cmd3.c

    r333 r346  
    14121412 
    14131413        /* Allocate the "who" array */ 
    1414         C_MAKE(who, z_info->r_max, u16b); 
     1414        who = C_ZNEW(z_info->r_max, u16b); 
    14151415 
    14161416        /* Collect matching monsters */ 
  • trunk/src/cmd4.c

    r337 r346  
    423423 
    424424        /* Sort everything into group order */ 
    425         C_MAKE(g_list, max_group + 1, int); 
    426         C_MAKE(g_offset, max_group + 1, int); 
     425        g_list = C_ZNEW(max_group + 1, int); 
     426        g_offset = C_ZNEW(max_group + 1, int); 
    427427 
    428428        for (i = 0; i < o_count; i++) 
     
    441441 
    442442        /* The compact set of group names, in display order */ 
    443         C_MAKE(g_names, grp_cnt, const char **); 
     443        g_names = C_ZNEW(grp_cnt, const char **); 
    444444 
    445445        for (i = 0; i < grp_cnt; i++) 
     
    11221122        } 
    11231123 
    1124         C_MAKE(default_join, m_count, join_t); 
    1125         C_MAKE(monsters, m_count, int); 
     1124        default_join = C_ZNEW(m_count, join_t); 
     1125        monsters = C_ZNEW(m_count, int); 
    11261126 
    11271127        m_count = 0; 
     
    11481148        display_knowledge("monsters", monsters, m_count, r_funcs, m_funcs, 
    11491149                                                "          Sym  Kills"); 
    1150         KILL(default_join); 
     1150        FREE(default_join); 
    11511151        FREE(monsters); 
    11521152} 
     
    12871287        int a_count = 0; 
    12881288 
    1289         C_MAKE(artifacts, z_info->a_max, int); 
     1289        artifacts = C_ZNEW(z_info->a_max, int); 
    12901290 
    12911291        /* Collect valid artifacts */ 
     
    14031403 
    14041404        /* HACK: currently no more than 3 tvals for one ego type */ 
    1405         C_MAKE(egoitems, z_info->e_max * EGO_TVALS_MAX, int); 
    1406         C_MAKE(default_join, z_info->e_max * EGO_TVALS_MAX, join_t); 
     1405        egoitems = C_ZNEW(z_info->e_max * EGO_TVALS_MAX, int); 
     1406        default_join = C_ZNEW(z_info->e_max * EGO_TVALS_MAX, join_t); 
    14071407 
    14081408        for (i = 0; i < z_info->e_max; i++) 
     
    14261426        display_knowledge("ego items", egoitems, e_count, obj_f, ego_f, ""); 
    14271427 
    1428         KILL(default_join); 
     1428        FREE(default_join); 
    14291429        FREE(egoitems); 
    14301430} 
     
    16521652        int i; 
    16531653 
    1654         C_MAKE(objects, z_info->k_max, int); 
     1654        objects = C_ZNEW(z_info->k_max, int); 
    16551655 
    16561656        for (i = 0; i < z_info->k_max; i++) 
     
    17291729        int f_count = 0; 
    17301730        int i; 
    1731         C_MAKE(features, z_info->f_max, int); 
     1731 
     1732        features = C_ZNEW(z_info->f_max, int); 
    17321733 
    17331734        for (i = 0; i < z_info->f_max; i++) 
     
    42004201                int gid = -1; 
    42014202 
    4202                 C_MAKE(obj_group_order, TV_GOLD+1, int); 
     4203                obj_group_order = C_ZNEW(TV_GOLD + 1, int); 
    42034204                atexit(cleanup_cmds); 
    42044205 
  • trunk/src/externs.h

    r336 r346  
    2121 
    2222extern int max_macrotrigger; 
    23 extern cptr macro_template; 
    24 extern cptr macro_modifier_chr; 
    25 extern cptr macro_modifier_name[MAX_MACRO_MOD]; 
    26 extern cptr macro_trigger_name[MAX_MACRO_TRIGGER]; 
    27 extern cptr macro_trigger_keycode[2][MAX_MACRO_TRIGGER]; 
     23extern char *macro_template; 
     24extern char *macro_modifier_chr; 
     25extern char *macro_modifier_name[MAX_MACRO_MOD]; 
     26extern char *macro_trigger_name[MAX_MACRO_TRIGGER]; 
     27extern char *macro_trigger_keycode[2][MAX_MACRO_TRIGGER]; 
    2828 
    2929/* pathfind.c */ 
     
    140140extern char savefile[1024]; 
    141141extern s16b macro__num; 
    142 extern cptr *macro__pat; 
    143 extern cptr *macro__act; 
     142extern char **macro__pat; 
     143extern char **macro__act; 
    144144extern term *angband_term[ANGBAND_TERM_MAX]; 
    145145extern char angband_term_name[ANGBAND_TERM_MAX][16]; 
     
    176176extern byte tval_to_attr[128]; 
    177177extern char macro_buffer[1024]; 
    178 extern cptr keymap_act[KEYMAP_MODES][256]; 
     178extern char *keymap_act[KEYMAP_MODES][256]; 
    179179extern const player_sex *sp_ptr; 
    180180extern const player_race *rp_ptr; 
     
    222222extern char *s_text; 
    223223extern s16b spell_list[MAX_REALMS][BOOKS_PER_REALM][SPELLS_PER_BOOK]; 
    224 extern cptr ANGBAND_SYS; 
    225 extern cptr ANGBAND_GRAF; 
    226 extern cptr ANGBAND_DIR; 
    227 extern cptr ANGBAND_DIR_APEX; 
    228 extern cptr ANGBAND_DIR_BONE; 
    229 extern cptr ANGBAND_DIR_DATA; 
    230 extern cptr ANGBAND_DIR_EDIT; 
    231 extern cptr ANGBAND_DIR_FILE; 
    232 extern cptr ANGBAND_DIR_HELP; 
    233 extern cptr ANGBAND_DIR_INFO; 
    234 extern cptr ANGBAND_DIR_SAVE; 
    235 extern cptr ANGBAND_DIR_PREF; 
    236 extern cptr ANGBAND_DIR_USER; 
    237 extern cptr ANGBAND_DIR_XTRA; 
     224extern const char *ANGBAND_SYS; 
     225extern const char *ANGBAND_GRAF; 
     226extern char *ANGBAND_DIR; 
     227extern char *ANGBAND_DIR_APEX; 
     228extern char *ANGBAND_DIR_BONE; 
     229extern char *ANGBAND_DIR_DATA; 
     230extern char *ANGBAND_DIR_EDIT; 
     231extern char *ANGBAND_DIR_FILE; 
     232extern char *ANGBAND_DIR_HELP; 
     233extern char *ANGBAND_DIR_INFO; 
     234extern char *ANGBAND_DIR_SAVE; 
     235extern char *ANGBAND_DIR_PREF; 
     236extern char *ANGBAND_DIR_USER; 
     237extern char *ANGBAND_DIR_XTRA; 
    238238extern bool item_tester_full; 
    239239extern byte item_tester_tval; 
  • trunk/src/files.c

    r337 r346  
    480480                        } 
    481481                } 
     482 
    482483                /* Macro trigger */ 
    483484                else if (tok >= 2) 
     
    494495 
    495496                        /* Buffer for the trigger name */ 
    496                         C_MAKE(buf, strlen(zz[0]) + 1, char); 
     497                        buf = C_ZNEW(strlen(zz[0]) + 1, char); 
    497498 
    498499                        /* Simulate strcpy() and skip the '\' escape character */ 
  • trunk/src/init1.c

    r325 r346  
    39243924 
    39253925        /* Allocate space for power */ 
    3926         C_MAKE(power, z_info->r_max, long); 
     3926        power = C_ZNEW(z_info->r_max, long); 
    39273927 
    39283928 
  • trunk/src/init2.c

    r305 r346  
    301301 
    302302 
    303         /* Allocate the "*_info" array */ 
    304         C_MAKE(head->info_ptr, head->info_size, char); 
    305  
    306         /* Read the "*_info" array */ 
     303        /* Allocate and read the "*_info" array */ 
     304        head->info_ptr = C_RNEW(head->info_size, char); 
    307305        fd_read(fd, head->info_ptr, head->info_size); 
    308306 
    309307        if (head->name_size) 
    310308        { 
    311                 /* Allocate the "*_name" array */ 
    312                 C_MAKE(head->name_ptr, head->name_size, char); 
    313  
    314                 /* Read the "*_name" array */ 
     309                /* Allocate and read the "*_name" array */ 
     310                head->name_ptr = C_RNEW(head->name_size, char); 
    315311                fd_read(fd, head->name_ptr, head->name_size); 
    316312        } 
     
    318314        if (head->text_size) 
    319315        { 
    320                 /* Allocate the "*_text" array */ 
    321                 C_MAKE(head->text_ptr, head->text_size, char); 
    322  
    323                 /* Read the "*_text" array */ 
     316                /* Allocate and read the "*_text" array */ 
     317                head->text_ptr = C_RNEW(head->text_size, char); 
    324318                fd_read(fd, head->text_ptr, head->text_size); 
    325319        } 
     
    438432 
    439433                /* Allocate the "*_info" array */ 
    440                 C_MAKE(head->info_ptr, head->info_size, char); 
     434                head->info_ptr = C_ZNEW(head->info_size, char); 
    441435 
    442436                /* MegaHack -- make "fake" arrays */ 
    443437                if (z_info) 
    444438                { 
    445                         C_MAKE(head->name_ptr, z_info->fake_name_size, char); 
    446                         C_MAKE(head->text_ptr, z_info->fake_text_size, char); 
     439                        head->name_ptr = C_ZNEW(z_info->fake_name_size, char); 
     440                        head->text_ptr = C_ZNEW(z_info->fake_text_size, char); 
    447441                } 
    448442 
     
    590584 
    591585                /* Free the "*_info" array */ 
    592                 KILL(head->info_ptr); 
     586                FREE(head->info_ptr); 
    593587 
    594588                /* MegaHack -- Free the "fake" arrays */ 
    595589                if (z_info) 
    596590                { 
    597                         KILL(head->name_ptr); 
    598                         KILL(head->text_ptr); 
     591                        FREE(head->name_ptr); 
     592                        FREE(head->text_ptr); 
    599593                } 
     594 
    600595 
    601596#endif /* ALLOW_TEMPLATES */ 
     
    10991094        inscriptions_count = 0; 
    11001095 
    1101         C_MAKE(inscriptions, AUTOINSCRIPTIONS_MAX, autoinscription); 
     1096        inscriptions = C_ZNEW(AUTOINSCRIPTIONS_MAX, autoinscription); 
    11021097} 
    11031098 
     
    11281123 
    11291124        /* Array of grids */ 
    1130         C_MAKE(view_g, VIEW_MAX, u16b); 
     1125        view_g = C_ZNEW(VIEW_MAX, u16b); 
    11311126 
    11321127        /* Array of grids */ 
    1133         C_MAKE(temp_g, TEMP_MAX, u16b); 
     1128        temp_g = C_ZNEW(TEMP_MAX, u16b); 
    11341129 
    11351130        /* Hack -- use some memory twice */ 
     
    11411136 
    11421137        /* Padded into array */ 
    1143         C_MAKE(cave_info, DUNGEON_HGT, byte_256); 
    1144         C_MAKE(cave_info2, DUNGEON_HGT, byte_256); 
     1138        cave_info = C_ZNEW(DUNGEON_HGT, byte_256); 
     1139        cave_info2 = C_ZNEW(DUNGEON_HGT, byte_256); 
    11451140 
    11461141        /* Feature array */ 
    1147         C_MAKE(cave_feat, DUNGEON_HGT, byte_wid); 
     1142        cave_feat = C_ZNEW(DUNGEON_HGT, byte_wid); 
    11481143 
    11491144        /* Entity arrays */ 
    1150         C_MAKE(cave_o_idx, DUNGEON_HGT, s16b_wid); 
    1151         C_MAKE(cave_m_idx, DUNGEON_HGT, s16b_wid); 
     1145        cave_o_idx = C_ZNEW(DUNGEON_HGT, s16b_wid); 
     1146        cave_m_idx = C_ZNEW(DUNGEON_HGT, s16b_wid); 
    11521147 
    11531148#ifdef MONSTER_FLOW 
    11541149 
    11551150        /* Flow arrays */ 
    1156         C_MAKE(cave_cost, DUNGEON_HGT, byte_wid); 
    1157         C_MAKE(cave_when, DUNGEON_HGT, byte_wid); 
     1151        cave_cost = C_ZNEW(DUNGEON_HGT, byte_wid); 
     1152        cave_when = C_ZNEW(DUNGEON_HGT, byte_wid); 
    11581153 
    11591154#endif /* MONSTER_FLOW */ 
     
    11681163 
    11691164        /* Objects */ 
    1170         C_MAKE(o_list, z_info->o_max, object_type); 
     1165        o_list = C_ZNEW(z_info->o_max, object_type); 
    11711166 
    11721167        /* Monsters */ 
    1173         C_MAKE(mon_list, z_info->m_max, monster_type); 
     1168        mon_list = C_ZNEW(z_info->m_max, monster_type); 
    11741169 
    11751170 
     
    11771172 
    11781173        /* Lore */ 
    1179         C_MAKE(l_list, z_info->r_max, monster_lore); 
     1174        l_list = C_ZNEW(z_info->r_max, monster_lore); 
    11801175 
    11811176 
     
    11831178 
    11841179        /* Quests */ 
    1185         C_MAKE(q_list, MAX_Q_IDX, quest); 
     1180        q_list = C_ZNEW(MAX_Q_IDX, quest); 
    11861181 
    11871182 
     
    11891184 
    11901185        /* Allocate it */ 
    1191         C_MAKE(inventory, INVEN_TOTAL, object_type); 
     1186        inventory = C_ZNEW(INVEN_TOTAL, object_type); 
    11921187 
    11931188 
     
    11951190 
    11961191        /* Allocate the stores */ 
    1197         C_MAKE(store, MAX_STORES, store_type); 
     1192        store = C_ZNEW(MAX_STORES, store_type); 
    11981193 
    11991194        /* Fill in each store */ 
     
    12091204 
    12101205                /* Allocate the stock */ 
    1211                 C_MAKE(st_ptr->stock, st_ptr->stock_size, object_type); 
     1206                st_ptr->stock = C_ZNEW(st_ptr->stock_size, object_type); 
    12121207 
    12131208                /* No table for the black market or home */ 
     
    12181213 
    12191214                /* Allocate the stock */ 
    1220                 C_MAKE(st_ptr->table, st_ptr->table_size, s16b); 
     1215                st_ptr->table = C_ZNEW(st_ptr->table_size, s16b); 
    12211216 
    12221217                /* Scan the choices */ 
     
    13411336 
    13421337        /* Allocate the alloc_kind_table */ 
    1343         C_MAKE(alloc_kind_table, alloc_kind_size, alloc_entry); 
     1338        alloc_kind_table = C_ZNEW(alloc_kind_size, alloc_entry); 
    13441339 
    13451340        /* Get the table entry */ 
     
    14271422 
    14281423        /* Allocate the alloc_race_table */ 
    1429         C_MAKE(alloc_race_table, alloc_race_size, alloc_entry); 
     1424        alloc_race_table = C_ZNEW(alloc_race_size, alloc_entry); 
    14301425 
    14311426        /* Get the table entry */ 
     
    15051500 
    15061501        /* Allocate the alloc_ego_table */ 
    1507         C_MAKE(alloc_ego_table, alloc_ego_size, alloc_entry); 
     1502        alloc_ego_table = C_ZNEW(alloc_ego_size, alloc_entry); 
    15081503 
    15091504        /* Get the table entry */ 
  • trunk/src/maid-x11.c

    r136 r346  
    337337 
    338338        /* Allocate image memory */ 
    339         C_MAKE(Data, total, char); 
     339        Data = C_ZNEW(total, char); 
    340340 
    341341        Res = XCreateImage(dpy, visual, depth, ZPixmap, 0 /*offset*/, 
     
    346346        if (Res == NULL) 
    347347        { 
    348                 KILL(Data); 
     348                FREE(Data); 
    349349                fclose(f); 
    350350                return (NULL); 
  • trunk/src/main-crb.c

    r185 r346  
    37143714/*** Some Hooks for various routines ***/ 
    37153715 
    3716 /* 
    3717  * Mega-Hack -- emergency lifeboat 
    3718  */ 
    3719 static void *lifeboat = NULL; 
    3720  
    3721  
    3722 /* 
    3723  * Hook to handle "out of memory" errors 
    3724  */ 
    3725 static void *hook_rpanic(huge size) 
    3726 { 
    3727 #pragma unused(size) 
    3728  
    3729         /* Free the lifeboat */ 
    3730         if (lifeboat) 
    3731         { 
    3732                 /* Free the lifeboat */ 
    3733                 free(lifeboat); 
    3734  
    3735                 /* Forget the lifeboat */ 
    3736                 lifeboat = NULL; 
    3737  
    3738                 /* Mega-Hack -- Warning */ 
    3739                 mac_warning("Running out of Memory!\nTerminate this process now!"); 
    3740  
    3741                 (void) pause(); 
    3742         } 
    3743  
    3744         /* Mega-Hack -- Crash */ 
    3745         return (NULL); 
    3746 } 
    37473716 
    37483717 
     
    38363805 
    38373806 
    3838         /* Hook in some "z-virt.c" hooks */ 
    3839         rnfree_aux = NULL; 
    3840         ralloc_aux = NULL; 
    3841         rpanic_aux = hook_rpanic; 
    38423807 
    38433808        /* Hooks in some "z-util.c" hooks */ 
     
    38833848        SetCursor(GetQDGlobalsArrow(&tempCursor)); 
    38843849 
    3885         /* Mega-Hack -- Allocate a "lifeboat" */ 
    3886         lifeboat = malloc(16384); 
    38873850 
    38883851        /* Quicktime -- Load sound effect resources */ 
  • trunk/src/main-sdl.c

    r232 r346  
    132132 * Directory names 
    133133 */ 
    134 static cptr ANGBAND_DIR_XTRA_FONT; 
    135 static cptr ANGBAND_DIR_XTRA_GRAF; 
     134static char *ANGBAND_DIR_XTRA_FONT; 
     135static char *ANGBAND_DIR_XTRA_GRAF; 
    136136 
    137137/* XXXXXXXXX */ 
    138 static cptr ANGBAND_DIR_USER_SDL; 
     138static char *ANGBAND_DIR_USER_SDL; 
    139139 
    140140/* Later... 
     
    148148 
    149149#define MAX_FONTS 20 
    150 cptr FontList[MAX_FONTS]; 
     150char *FontList[MAX_FONTS]; 
    151151static int num_fonts = 0; 
    152152 
     
    198198         
    199199        sdl_Font font;                  /* Font info */ 
    200         cptr req_font;                        /* Requested font */ 
     200        char *req_font;                       /* Requested font */ 
    201201        int rows;                               /* Dimension in tiles */ 
    202202        int cols; 
     
    508508{ 
    509509        /* The only memory reserved is the data */ 
    510         if (font->data) FREE(font->data); 
    511          
    512         font->data = NULL; 
     510        FREE(font->data); 
    513511} 
    514512 
     
    555553         
    556554        /* Make a very large temporary holding bin for pixel offset data  XXX */ 
    557         C_MAKE(temp_array, NUM_GLYPHS * 1000, int); 
     555        temp_array = C_ZNEW(NUM_GLYPHS * 1000, int); 
    558556         
    559557        /* Render and encode all the characters */ 
     
    604602         
    605603        /* Make a pixel access array for this font */ 
    606         C_MAKE(font->data, num_pixels, int); 
     604        font->data = C_ZNEW(num_pixels, int); 
    607605         
    608606        /* Save the data gathered in our temporary array */ 
     
    788786{ 
    789787        bank->window = window; 
    790          
    791         C_MAKE(bank->buttons, MAX_BUTTONS, sdl_Button); 
    792         C_MAKE(bank->used, MAX_BUTTONS, bool); 
     788        bank->buttons = C_ZNEW(MAX_BUTTONS, sdl_Button); 
     789        bank->used = C_ZNEW(MAX_BUTTONS, bool); 
    793790        bank->need_update = TRUE; 
    794791} 
     
    11181115         
    11191116        for (i = 0; i < MAX_FONTS; i++) 
    1120         { 
    1121                 if (FontList[i]) string_free(FontList[i]); 
    1122         } 
     1117                string_free(FontList[i]); 
    11231118} 
    11241119 
  • trunk/src/monster2.c

    r305 r346  
    582582 
    583583        /* Allocate the array */ 
    584         C_MAKE(race_count, z_info->r_max, u16b); 
     584        race_count = C_ZNEW(z_info->r_max, u16b); 
    585585 
    586586        /* Scan the monster list */ 
  • trunk/src/randart.c

    r189 r346  
    4949 
    5050        /* Temporary space for names, while reading and randomizing them. */ 
    51         cptr *names; 
     51        char **names; 
    5252 
    5353        /* Allocate the "names" array */ 
    5454        /* ToDo: Make sure the memory is freed correctly in case of errors */ 
    55         C_MAKE(names, z_info->a_max, cptr); 
     55        names = C_ZNEW(z_info->a_max, cptr); 
    5656 
    5757        for (i = 0; i < z_info->a_max; i++) 
     
    8585        } 
    8686 
    87         C_MAKE(a_base, name_size, char); 
     87        a_base = C_ZNEW(name_size, char); 
    8888 
    8989        a_next = a_base + 1;    /* skip first char */ 
     
    13671367{ 
    13681368        /* Allocate the "kinds" array */ 
    1369         C_MAKE(kinds, z_info->a_max, s16b); 
     1369        kinds = C_ZNEW(z_info->a_max, s16b); 
    13701370 
    13711371        while (1) 
  • trunk/src/snd-sdl.c

    r262 r346  
    4343        int num;                        /* Number of samples for this event */ 
    4444        Mix_Chunk *wavs[MAX_SAMPLES];   /* Sample array */ 
    45         const char *paths[MAX_SAMPLES]; /* Relative pathnames for samples */ 
     45        char *paths[MAX_SAMPLES]; /* Relative pathnames for samples */ 
    4646} sample_list; 
    4747 
  • trunk/src/squelch.c

    r294 r346  
    708708 
    709709        /* Create the array */ 
    710         C_MAKE(choice, z_info->k_max, u16b); 
     710        choice = C_ZNEW(z_info->k_max, u16b); 
    711711 
    712712        /* Iterate over all possible object kinds, finding ones which can be squelched */ 
  • trunk/src/ui.c

    r270 r346  
    160160        listener_list *link; 
    161161 
    162         MAKE(link, listener_list); 
     162        link = ZNEW(listener_list); 
    163163        link->listener = observer; 
    164164        link->next = target->observers; 
     
    10361036void menu_set_filter(menu_type *menu, const int object_list[], int n) 
    10371037{ 
    1038         menu->object_list = object_list; 
     1038        menu->object_list = (int *)object_list; 
    10391039        menu->filter_count = n; 
    10401040} 
     
    10451045void menu_release_filter(menu_type *menu) 
    10461046{ 
    1047         if (menu->object_list) 
    1048                 FREE((void *)menu->object_list); 
    1049         menu->object_list = 0; 
     1047        FREE(menu->object_list); 
    10501048        menu->filter_count = menu->count; 
    10511049} 
     
    11431141void menu_destroy(menu_type *menu) 
    11441142{ 
    1145         if (menu->object_list) 
    1146                 FREE((void *)menu->object_list); 
     1143        FREE(menu->object_list); 
    11471144} 
    11481145 
  • trunk/src/ui.h

    r256 r346  
    313313        int flags; 
    314314        int filter_count;               /* number of rows in current view */ 
    315         const int *object_list;       /* optional filter (view) of menu objects */ 
     315        int *object_list;             /* optional filter (view) of menu objects */ 
    316316        int count;                              /* number of rows in underlying data set */ 
    317317        const void *menu_data;  /* the data used to access rows. */ 
  • trunk/src/util.c

    r312 r346  
    680680{ 
    681681        /* Macro patterns */ 
    682         C_MAKE(macro__pat, MACRO_MAX, cptr); 
     682        macro__pat = C_ZNEW(MACRO_MAX, cptr); 
    683683 
    684684        /* Macro actions */ 
    685         C_MAKE(macro__act, MACRO_MAX, cptr); 
     685        macro__act = C_ZNEW(MACRO_MAX, cptr); 
    686686 
    687687        /* Success */ 
     
    704704        } 
    705705 
    706         FREE((void*)macro__pat); 
    707         FREE((void*)macro__act); 
     706        FREE(macro__pat); 
     707        FREE(macro__act); 
    708708 
    709709        /* Free the keymaps */ 
     
    753753                /* Free modifier names */ 
    754754                for (i = 0; i < num; i++) 
    755                 { 
    756755                        string_free(macro_modifier_name[i]); 
    757                 } 
    758756 
    759757                /* Free modifier chars */ 
    760758                string_free(macro_modifier_chr); 
    761                 macro_modifier_chr = NULL; 
    762759        } 
    763760 
     
    14081405 * The array[QUARK_MAX] of pointers to the quarks 
    14091406 */ 
    1410 static cptr *quark__str; 
     1407static char **quark__str; 
    14111408 
    14121409 
     
    14631460{ 
    14641461        /* Quark variables */ 
    1465         C_MAKE(quark__str, QUARK_MAX, cptr); 
     1462        quark__str = C_ZNEW(QUARK_MAX, const char *); 
    14661463 
    14671464        /* Success */ 
     
    14791476        /* Free the "quarks" */ 
    14801477        for (i = 1; i < quark__num; i++) 
    1481         { 
    14821478                string_free(quark__str[i]); 
    1483         } 
    14841479 
    14851480        /* Free the list of "quarks" */ 
     
    19151910{ 
    19161911        /* Message variables */ 
    1917         C_MAKE(message__ptr, MESSAGE_MAX, u16b); 
    1918         C_MAKE(message__buf, MESSAGE_BUF, char); 
    1919         C_MAKE(message__type, MESSAGE_MAX, u16b); 
    1920         C_MAKE(message__count, MESSAGE_MAX, u16b); 
     1912        message__ptr = C_ZNEW(MESSAGE_MAX, u16b); 
     1913        message__buf = C_ZNEW(MESSAGE_BUF, char); 
     1914        message__type = C_ZNEW(MESSAGE_MAX, u16b); 
     1915        message__count = C_ZNEW(MESSAGE_MAX, u16b); 
    19211916 
    19221917        /* Init the message colors to white */ 
    1923         (void)C_BSET(message__color, TERM_WHITE, MSG_MAX, byte); 
     1918        memset(message__color, TERM_WHITE, MSG_MAX); 
    19241919 
    19251920        /* Hack -- No messages yet */ 
  • trunk/src/variable.c

    r305 r346  
    152152 * Array of macro patterns [MACRO_MAX] 
    153153 */ 
    154 cptr *macro__pat; 
     154char **macro__pat; 
    155155 
    156156/* 
    157157 * Array of macro actions [MACRO_MAX] 
    158158 */ 
    159 cptr *macro__act; 
     159char **macro__act; 
    160160 
    161161 
     
    185185 
    186186int max_macrotrigger = 0; 
    187 cptr macro_template = NULL; 
    188 cptr macro_modifier_chr; 
    189 cptr macro_modifier_name[MAX_MACRO_MOD]; 
    190 cptr macro_trigger_name[MAX_MACRO_TRIGGER]; 
    191 cptr macro_trigger_keycode[2][MAX_MACRO_TRIGGER]; 
     187char *macro_template = NULL; 
     188char *macro_modifier_chr; 
     189char *macro_modifier_name[MAX_MACRO_MOD]; 
     190char *macro_trigger_name[MAX_MACRO_TRIGGER]; 
     191char *macro_trigger_keycode[2][MAX_MACRO_TRIGGER]; 
    192192 
    193193 
     
    538538 * Keymaps for each "mode" associated with each keypress. 
    539539 */ 
    540 cptr keymap_act[KEYMAP_MODES][256]; 
     540char *keymap_act[KEYMAP_MODES][256]; 
    541541 
    542542 
     
    683683 * This variable is used to choose an appropriate "pref-xxx" file 
    684684 */ 
    685 cptr ANGBAND_SYS = "xxx"; 
     685const char *ANGBAND_SYS = "xxx"; 
    686686 
    687687/* 
     
    689689 * This variable is used to choose an appropriate "graf-xxx" file 
    690690 */ 
    691 cptr ANGBAND_GRAF = "old"; 
     691const char *ANGBAND_GRAF = "old"; 
    692692 
    693693/* 
     
    695695 * This variable is not actually used anywhere in the code 
    696696 */ 
    697 cptr ANGBAND_DIR; 
    698  
    699 /* 
    700  * High score files (binary) 
    701  * These files may be portable between platforms 
    702  */ 
    703 cptr ANGBAND_DIR_APEX; 
    704  
    705 /* 
    706  * Bone files for player ghosts (ascii) 
    707  * These files are portable between platforms 
    708  */ 
    709 cptr ANGBAND_DIR_BONE; 
    710  
    711 /* 
    712  * Binary image files for the "*_info" arrays (binary) 
    713  * These files are not portable between platforms 
    714  */ 
    715 cptr ANGBAND_DIR_DATA; 
    716  
    717 /* 
    718  * Textual template files for the "*_info" arrays (ascii) 
    719  * These files are portable between platforms 
    720  */ 
    721 cptr ANGBAND_DIR_EDIT; 
    722  
    723 /* 
    724  * Various extra files (ascii) 
    725  * These files may be portable between platforms 
    726  */ 
    727 cptr ANGBAND_DIR_FILE; 
    728  
    729 /* 
    730  * Help files (normal) for the online help (ascii) 
    731  * These files are portable between platforms 
    732  */ 
    733 cptr ANGBAND_DIR_HELP; 
    734  
    735 /* 
    736  * Help files (spoilers) for the online help (ascii) 
    737  * These files are portable between platforms 
    738  */ 
    739 cptr ANGBAND_DIR_INFO; 
    740  
    741 /* 
    742  * Savefiles for current characters (binary) 
    743  * These files are portable between platforms 
    744  */ 
    745 cptr ANGBAND_DIR_SAVE; 
    746  
    747 /* 
    748  * Default user "preference" files (ascii) 
    749  * These files are rarely portable between platforms 
    750  */ 
    751 cptr ANGBAND_DIR_PREF; 
    752  
    753 /* 
    754  * User defined "preference" files (ascii) 
    755  * These files are rarely portable between platforms 
    756  */ 
    757 cptr ANGBAND_DIR_USER; 
    758  
    759 /* 
    760  * Various extra files (binary) 
    761  * These files are rarely portable between platforms 
    762  */ 
    763 cptr ANGBAND_DIR_XTRA; 
     697char *ANGBAND_DIR; 
     698 
     699/* 
     700 * Various lib/ sub-directories. 
     701 */ 
     702char *ANGBAND_DIR_APEX; 
     703char *ANGBAND_DIR_BONE; 
     704char *ANGBAND_DIR_DATA; 
     705char *ANGBAND_DIR_EDIT; 
     706char *ANGBAND_DIR_FILE; 
     707char *ANGBAND_DIR_HELP; 
     708char *ANGBAND_DIR_INFO; 
     709char *ANGBAND_DIR_SAVE; 
     710char *ANGBAND_DIR_PREF; 
     711char *ANGBAND_DIR_USER; 
     712char *ANGBAND_DIR_XTRA; 
    764713 
    765714 
  • trunk/src/wizard1.c

    r189 r346  
    577577 
    578578        /* Allocate the "who" array */ 
    579         C_MAKE(who, z_info->r_max, u16b); 
     579        who = C_ZNEW(z_info->r_max, u16b); 
    580580 
    581581        /* Scan the monsters (except the ghost) */ 
     
    715715 
    716716        /* Allocate the "who" array */ 
    717         C_MAKE(who, z_info->r_max, u16b); 
     717        who = C_ZNEW(z_info->r_max, u16b); 
    718718 
    719719        /* Scan the monsters */ 
  • trunk/src/z-file.c

    r213 r346  
    841841{ 
    842842        HANDLE h; 
    843         const char *first_file; 
     843        char *first_file; 
    844844}; 
    845845 
     
    859859 
    860860        /* Allocate for the handle */ 
    861         dir = ralloc(sizeof dir); 
     861        dir = ZNEW(ang_dir); 
    862862        if (!dir) return NULL; 
    863863 
     
    933933{ 
    934934        DIR *d; 
    935         const char *dirname; 
     935        char *dirname; 
    936936}; 
    937937 
     
    947947 
    948948        /* Allocate memory for the handle */ 
    949         dir = ralloc(sizeof dir); 
     949        dir = ZNEW(ang_dir); 
    950950        if (!dir)  
    951951        { 
  • trunk/src/z-form.c

    r232 r346  
    692692        { 
    693693                format_len = 1024; 
    694                 C_MAKE(format_buf, format_len, char); 
     694                format_buf = C_RNEW(format_len, char); 
     695                format_buf[0] = 0; 
    695696        } 
    696697 
     
    710711 
    711712                /* Grow the buffer */ 
    712                 KILL(format_buf); 
    713713                format_len = format_len * 2; 
    714                 C_MAKE(format_buf, format_len, char); 
     714                format_buf = mem_realloc(format_buf, format_len); 
    715715        } 
    716716 
     
    721721void vformat_kill(void) 
    722722{ 
    723         KILL(format_buf); 
     723        FREE(format_buf); 
    724724} 
    725725 
  • trunk/src/z-term.c

    r120 r346  
    290290{ 
    291291        /* Free the window access arrays */ 
    292         KILL(s->a); 
    293         KILL(s->c); 
     292        FREE(s-&