OSDN Git Service

C_MAKEに対応するC_KILLがなくてメモリリークしていた場所をすべて修正。
authorhabu <habu@0568b783-4c39-0410-ac80-bf13821ea2a2>
Thu, 17 Jan 2002 18:24:00 +0000 (18:24 +0000)
committerhabu <habu@0568b783-4c39-0410-ac80-bf13821ea2a2>
Thu, 17 Jan 2002 18:24:00 +0000 (18:24 +0000)
src/bldg.c
src/cmd3.c
src/cmd4.c
src/cmd6.c
src/spells3.c
src/wizard1.c

index 169bfdd..9ebd150 100644 (file)
@@ -4253,6 +4253,9 @@ msg_print("
 
                                        if (i == ESCAPE)
                                        {
+                                               /* Free the "dun" array */
+                                               C_KILL(dun, max_d_idx, s16b);
+
                                                screen_load();
                                                return;
                                        }
@@ -4265,6 +4268,9 @@ msg_print("
                                }
                                screen_load();
 
+                               /* Free the "dun" array */
+                               C_KILL(dun, max_d_idx, s16b);
+
                                max_depth = d_info[select_dungeon].maxdepth;
 
                                /* Limit depth in Angband */
index 24e8837..20d8add 100644 (file)
@@ -2677,9 +2677,6 @@ void do_cmd_query_symbol(void)
        u16b    why = 0;
        u16b    *who;
 
-       /* Allocate the "who" array */
-       C_MAKE(who, max_r_idx, u16b);
-
        /* Get a character, or abort */
 #ifdef JP
        if (!get_com("ÃΤꤿ¤¤Ê¸»ú¤òÆþÎϤ·¤Æ²¼¤µ¤¤(µ­¹æ or ^AÁ´,^U¥æ,^NÈó¥æ,^M̾Á°): ", &sym, FALSE)) return;
@@ -2761,6 +2758,8 @@ void do_cmd_query_symbol(void)
        /* Display the result */
        prt(buf, 0, 0);
 
+       /* Allocate the "who" array */
+       C_MAKE(who, max_r_idx, u16b);
 
        /* Collect matching monsters */
        for (n = 0, i = 1; i < max_r_idx; i++)
@@ -2808,7 +2807,13 @@ void do_cmd_query_symbol(void)
        }
 
        /* Nothing to recall */
-       if (!n) return;
+       if (!n)
+       {
+               /* Free the "who" array */
+               C_KILL(who, max_r_idx, u16b);
+
+               return;
+       }
 
 
        /* Prompt XXX XXX XXX */
@@ -2842,7 +2847,13 @@ void do_cmd_query_symbol(void)
        }
 
        /* Catch "escape" */
-       if (query != 'y') return;
+       if (query != 'y')
+       {
+               /* Free the "who" array */
+               C_KILL(who, max_r_idx, u16b);
+
+               return;
+       }
 
        /* Sort if needed */
        if (why == 4)
@@ -2944,6 +2955,9 @@ void do_cmd_query_symbol(void)
                }
        }
 
+       /* Free the "who" array */
+       C_KILL(who, max_r_idx, u16b);
+
        /* Re-display the identity */
        prt(buf, 0, 0);
 }
@@ -3003,9 +3017,6 @@ if (!get_com("
                return (FALSE);
        }
 
-       /* Allocate the "who" array */
-       C_MAKE(who, max_r_idx, u16b);
-
        /* Find that character info, and describe it */
        for (i = 0; ident_info[i]; ++i)
        {
@@ -3076,6 +3087,9 @@ sprintf(buf, "%c - %s", sym, "̵
        prt(buf, 16, 10);
 
 
+       /* Allocate the "who" array */
+       C_MAKE(who, max_r_idx, u16b);
+
        /* Collect matching monsters */
        for (n = 0, i = 1; i < max_r_idx; i++)
        {
index 025c986..925c22a 100644 (file)
@@ -5433,14 +5433,9 @@ void do_cmd_knowledge_artifacts(void)
 
        bool *okay;
 
-       /* Allocate the "who" array */
-       C_MAKE(who, max_r_idx, s16b);
-
-       /* Allocate the "okay" array */
-       C_MAKE(okay, max_a_idx, bool);
-
        /* Open a new file */
        fff = my_fopen_temp(file_name, 1024);
+
        if (!fff) {
 #ifdef JP
            msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
@@ -5451,6 +5446,12 @@ void do_cmd_knowledge_artifacts(void)
            return;
        }
 
+       /* Allocate the "who" array */
+       C_MAKE(who, max_r_idx, s16b);
+
+       /* Allocate the "okay" array */
+       C_MAKE(okay, max_a_idx, bool);
+
        /* Scan the artifacts */
        for (k = 0; k < max_a_idx; k++)
        {
@@ -5575,6 +5576,12 @@ strcpy(base_name, "̤
 
        }
 
+       /* Free the "who" array */
+       C_KILL(who, max_r_idx, s16b);
+
+       /* Free the "okay" array */
+       C_KILL(okay, max_a_idx, bool);
+
        /* Close the file */
        my_fclose(fff);
 
@@ -5604,11 +5611,9 @@ static void do_cmd_knowledge_uniques(void)
 
        char file_name[1024];
 
-       /* Allocate the "who" array */
-       C_MAKE(who, max_r_idx, s16b);
-
        /* Open a new file */
        fff = my_fopen_temp(file_name, 1024);
+
        if (!fff) {
 #ifdef JP
            msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
@@ -5619,6 +5624,9 @@ static void do_cmd_knowledge_uniques(void)
            return;
        }
 
+       /* Allocate the "who" array */
+       C_MAKE(who, max_r_idx, s16b);
+
        /* Scan the monsters */
        for (i = 1; i < max_r_idx; i++)
        {
@@ -5663,6 +5671,9 @@ static void do_cmd_knowledge_uniques(void)
                }
        }
 
+       /* Free the "who" array */
+       C_KILL(who, max_r_idx, s16b);
+
        /* Close the file */
        my_fclose(fff);
 
@@ -5692,11 +5703,9 @@ static void do_cmd_knowledge_uniques_dead(void)
 
        char file_name[1024];
 
-       /* Allocate the "who" array */
-       C_MAKE(who, max_r_idx, s16b);
-
        /* Open a new file */
        fff = my_fopen_temp(file_name, 1024);
+
        if (!fff) {
 #ifdef JP
            msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
@@ -5707,6 +5716,9 @@ static void do_cmd_knowledge_uniques_dead(void)
            return;
        }
 
+       /* Allocate the "who" array */
+       C_MAKE(who, max_r_idx, s16b);
+
        /* Scan the monsters */
        for (i = 1; i < max_r_idx; i++)
        {
@@ -5751,6 +5763,9 @@ static void do_cmd_knowledge_uniques_dead(void)
                }
        }
 
+       /* Free the "who" array */
+       C_KILL(who, max_r_idx, s16b);
+
        /* Close the file */
        my_fclose(fff);
 
@@ -6236,11 +6251,9 @@ static void do_cmd_knowledge_kill_count(void)
        s32b Total = 0;
 
 
-       /* Allocate the "who" array */
-       C_MAKE(who, max_r_idx, s16b);
-
        /* Open a new file */
        fff = my_fopen_temp(file_name, 1024);
+
        if (!fff) {
 #ifdef JP
            msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
@@ -6251,6 +6264,9 @@ static void do_cmd_knowledge_kill_count(void)
            return;
        }
 
+       /* Allocate the "who" array */
+       C_MAKE(who, max_r_idx, s16b);
+
        {
                /* Monsters slain */
                int kk;
@@ -6385,6 +6401,9 @@ fprintf(fff, "     %3d ɤ
 #endif
 
 
+       /* Free the "who" array */
+       C_KILL(who, max_r_idx, s16b);
+
        /* Close the file */
        my_fclose(fff);
 
index bdcdee3..19cf349 100644 (file)
@@ -6114,6 +6114,9 @@ msg_print("
                                pet_ctr = who[i];
                                teleport_to_player(pet_ctr, 100);
                        }
+
+                       /* Free the "who" array */
+                       C_KILL(who, max_m_idx, u16b);
                }
                o_ptr->timeout = 100+randint(100);
                return;
index d3e716b..ace5a18 100644 (file)
@@ -708,6 +708,9 @@ static int choose_dungeon(cptr note)
                i = inkey();
                if (i == ESCAPE)
                {
+                       /* Free the "dun" array */
+                       C_KILL(dun, max_d_idx, s16b);
+
                        screen_load();
                        return 0;
                }
@@ -719,6 +722,10 @@ static int choose_dungeon(cptr note)
                else bell();
        }
        screen_load();
+
+       /* Free the "dun" array */
+       C_KILL(dun, max_d_idx, s16b);
+
        return select_dungeon;
 }
 
index 8c190da..667940d 100644 (file)
@@ -1625,9 +1625,6 @@ static void spoil_mon_desc(cptr fname)
        char hp[80];
        char exp[80];
 
-       /* Allocate the "who" array */
-       C_MAKE(who, max_r_idx, s16b);
-
        /* Build the filename */
        path_build(buf, 1024, ANGBAND_DIR_USER, fname);
 
@@ -1644,6 +1641,9 @@ static void spoil_mon_desc(cptr fname)
                return;
        }
 
+       /* Allocate the "who" array */
+       C_MAKE(who, max_r_idx, s16b);
+
        /* Dump the header */
 
 #ifndef FAKE_VERSION
@@ -1752,6 +1752,9 @@ static void spoil_mon_desc(cptr fname)
        fprintf(fff, "\n");
 
 
+       /* Free the "who" array */
+       C_KILL(who, max_r_idx, s16b);
+
        /* Check for errors */
        if (ferror(fff) || my_fclose(fff))
        {
@@ -3140,6 +3143,9 @@ case RBE_DR_MANA: q = "
                spoil_out(NULL);
        }
 
+       /* Free the "who" array */
+       C_KILL(who, max_r_idx, s16b);
+
        /* Check for errors */
        if (ferror(fff) || my_fclose(fff))
        {