From 548c021049e2e48e367a4c030249549a2693fc2b Mon Sep 17 00:00:00 2001 From: nhmall Date: Tue, 10 Dec 2024 13:32:57 -0500 Subject: [PATCH] freedynamicdata() adjustment The location of the call to dobjsfree() in freedynamicdata() appears to have been non-ideal. After getting complaints from a leak-sensing tool after #quit, the source of the leaks was investigated. The call to dobjsfree() had been placed immediately following a call to dmonsfree(), and it did clear out the go.objs_deleted chain at that point. Further investigation revealed that the following functions later on in freedynamicdata() were then adding more deleted objects to the go.objs_deleted chain: free_current_level(); freeobjchn(gi.invent); freeobjchn(gm.migrating_objs); Move the call to dobjsfree() to a location after those listed above. --- src/save.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/save.c b/src/save.c index b98194da7..1497c4d5b 100644 --- a/src/save.c +++ b/src/save.c @@ -1213,7 +1213,6 @@ freedynamicdata(void) /* move-specific data */ dmonsfree(); /* release dead monsters */ - dobjsfree(); alloc_itermonarr(0U); /* a request of 0 releases existing allocation */ /* level-specific data */ @@ -1226,6 +1225,8 @@ freedynamicdata(void) free_light_sources(RANGE_GLOBAL); freeobjchn(gi.invent); freeobjchn(gm.migrating_objs); + if (go.objs_deleted) + dobjsfree(); /* really free deleted objects */ freemonchn(gm.migrating_mons); freemonchn(gm.mydogs); /* ascension or dungeon escape */ /* freelevchn(); -- [folded into free_dungeons()] */