Files
nethack/include
PatR 78252de3bc fix memory leak in iter_mons_safe()
While hunting for a memory leak in object allocation--which I haven't
found yet--I discovered one in monster movement.  iter_mons_safe()
allocates an array of (monst *) pointers for the monsters on the
current level, loops over that array to call a function for each
one, then frees the array.  But if the game ends while that called
function is running, execution never returns to iter_mons_safe() so
it wasn't able to free the memory.

Since that can happen at most once per game, it wasn't a signifcant
leak.  This fixes it anyway.

There was a second issue:  make sure that iter_mons_safe() doesn't
call alloc(0) to make the temporary array for zero monsters when
there aren't any on the level.  That might not be able to happen for
monster movement but the routine is written to be more general than
just movement.  alloc(0) could confuse the MONITOR_HEAP code.  In
C89/C90 I think malloc(0) is allowed to return NULL (don't recall
for sure; maybe that was just known pre-standard behavior for some
implementations).  Null return would trigger a panic even without
MONITOR_HEAP.  Don't know about C99 and later.
2024-01-23 23:04:06 -08:00
..
2022-02-04 11:01:20 -05:00
2022-03-13 13:58:56 -07:00
2022-07-19 21:23:26 +03:00
2023-12-16 06:16:51 -05:00
2022-11-29 21:53:21 -05:00
2023-09-16 20:16:51 -04:00
2023-05-22 20:50:35 -04:00
2024-01-04 10:37:38 -05:00
2022-06-30 23:48:18 -04:00
2023-12-22 19:24:09 -05:00
2024-01-23 23:04:06 -08:00
2023-12-06 21:41:49 -05:00
2023-03-01 14:00:29 +02:00
2021-01-26 21:06:16 -05:00
2023-05-04 06:02:23 -07:00
2024-01-23 18:50:35 -05:00
2023-05-22 14:43:01 -07:00
2024-01-07 12:03:45 -08:00
2024-01-09 17:17:19 -08:00
2022-07-01 08:36:03 -04:00
2022-03-11 07:33:28 -05:00
2022-06-19 02:30:45 -07:00
2023-12-09 12:43:41 +02:00
2022-11-29 21:53:21 -05:00
2023-02-25 07:02:19 -08:00
2024-01-12 17:06:47 -08:00
2023-06-14 15:54:04 -07:00
2023-11-22 16:01:58 -05:00
2022-10-26 14:21:23 -04:00
2022-10-26 14:21:23 -04:00
2022-10-26 14:21:23 -04:00
2023-10-16 09:11:05 -04:00
2022-07-23 23:11:13 -07:00
2023-02-25 18:05:09 +02:00
2022-11-29 21:53:21 -05:00
2023-11-22 16:01:58 -05:00
2023-11-22 16:01:58 -05:00
2020-08-12 16:15:28 -07:00
2024-01-12 14:17:50 -08:00
2023-12-27 20:11:59 -05:00
2023-11-22 16:01:58 -05:00
2022-11-29 21:53:21 -05:00
2023-11-22 16:01:58 -05:00
2022-06-30 23:48:18 -04:00
2023-11-22 16:01:58 -05:00
2023-11-22 16:01:58 -05:00
2023-11-20 00:47:12 -08:00
2023-11-22 16:01:58 -05:00
2022-10-26 14:21:23 -04:00
2022-10-26 14:21:23 -04:00