]> granicus.if.org Git - nethack/commitdiff
window cleanup at exit
authorPatR <rankin@nethack.org>
Sun, 15 Nov 2015 08:32:56 +0000 (00:32 -0800)
committerPatR <rankin@nethack.org>
Sun, 15 Nov 2015 08:32:56 +0000 (00:32 -0800)
exit_nhwindows() is called before terminate(), and the tty incarnation
destroys all windows--including 'pickinv_cache_win'--without setting
the various index variables used to access them to WIN_ERR, then
terminate() calls freedynamicdata() which calls free_pickinv_cache()
which tries to destroy 'pickinv_cache_win' since it isn't WIN_ERR (if
the perm_invent option has been enabled during that playing session).
Some of the other <interface>_exit_nhwindows() also tear things down
without resetting the variables used to track them, so fixing this in
exit_nhwindows() would have been pretty messy.

Call free_pickinv_cache() before exit_nhwindows() in done().  At the
moment it's only called from done(), so other exit paths won't release
the small chunk(s) of memory used for the alternate inventory window
(if it got created for perm_invent support).

src/end.c
src/invent.c
src/save.c

index c8560b21771ce1e17c83497e6fd19cbce346a9a1..e7c9da20a95e2a4c13a354f1de1f4c89f30dd8d3 100644 (file)
--- a/src/end.c
+++ b/src/end.c
@@ -1,4 +1,4 @@
-/* NetHack 3.6 end.c   $NHDT-Date: 1446510332 2015/11/03 00:25:32 $  $NHDT-Branch: master $:$NHDT-Revision: 1.102 $ */
+/* NetHack 3.6 end.c   $NHDT-Date: 1447576343 2015/11/15 08:32:23 $  $NHDT-Branch: master $:$NHDT-Revision: 1.103 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1094,6 +1094,7 @@ die:
     /* clean up unneeded windows */
     if (have_windows) {
         wait_synch();
+        free_pickinv_cache(); /* extra persistent window if perm_invent */
         if (WIN_INVEN != WIN_ERR)
             destroy_nhwindow(WIN_INVEN),  WIN_INVEN = WIN_ERR;
         display_nhwindow(WIN_MESSAGE, TRUE);
@@ -1122,13 +1123,12 @@ die:
     }
 
     if (!done_stopprint) {
-        Sprintf(
-            pbuf, "%s %s the %s...", Goodbye(), plname,
-            how != ASCENDED
-                ? (const char *) ((flags.female && urole.name.f)
+        Sprintf(pbuf, "%s %s the %s...", Goodbye(), plname,
+                (how != ASCENDED)
+                 ? (const char *) ((flags.female && urole.name.f)
                                       ? urole.name.f
                                       : urole.name.m)
-                : (const char *) (flags.female ? "Demigoddess" : "Demigod"));
+                 : (const char *) (flags.female ? "Demigoddess" : "Demigod"));
         putstr(endwin, 0, pbuf);
         putstr(endwin, 0, "");
     }
@@ -1254,10 +1254,9 @@ die:
         putstr(endwin, 0, pbuf);
     }
     if (!done_stopprint) {
-        Sprintf(
-            pbuf,
+        Sprintf(pbuf,
             "You were level %d with a maximum of %d hit point%s when you %s.",
-            u.ulevel, u.uhpmax, plur(u.uhpmax), ends[how]);
+                u.ulevel, u.uhpmax, plur(u.uhpmax), ends[how]);
         putstr(endwin, 0, pbuf);
         putstr(endwin, 0, "");
     }
index 5309d3b8d143c4e6258f4ad089a646eb99b14e1b..430894aabc703d7445cf312bbfa4cc0a01adf8b1 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 invent.c        $NHDT-Date: 1446516832 2015/11/03 02:13:52 $  $NHDT-Branch: master $:$NHDT-Revision: 1.178 $ */
+/* NetHack 3.6 invent.c        $NHDT-Date: 1447576348 2015/11/15 08:32:28 $  $NHDT-Branch: master $:$NHDT-Revision: 1.179 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1985,7 +1985,6 @@ struct obj *list, **last_found;
    then regrown to full inventory, possibly being resized in the process */
 static winid cached_pickinv_win = WIN_ERR;
 
-/* #ifdef FREE_ALL_MEMORY */
 void
 free_pickinv_cache()
 {
@@ -1994,7 +1993,6 @@ free_pickinv_cache()
         cached_pickinv_win = WIN_ERR;
     }
 }
-/* #endif */
 
 /*
  * Internal function used by display_inventory and getobj that can display
index dccd3a78511c2f34673136d6e988ce2b45364c06..41dd65a0451306b95dc66ef0d52d8d6f599535ca 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 save.c  $NHDT-Date: 1447124658 2015/11/10 03:04:18 $  $NHDT-Branch: master $:$NHDT-Revision: 1.93 $ */
+/* NetHack 3.6 save.c  $NHDT-Date: 1447576350 2015/11/15 08:32:30 $  $NHDT-Branch: master $:$NHDT-Revision: 1.94 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1395,7 +1395,7 @@ freedynamicdata()
     free_autopickup_exceptions();
 
     /* miscellaneous */
-    free_pickinv_cache();
+    /* free_pickinv_cache();  --  done from done()... */
     free_symsets();
 #endif /* FREE_ALL_MEMORY */
 #ifdef STATUS_VIA_WINDOWPORT