fix memory leak when simulating real threats default tip

Fri, 12 Jun 2026 15:32:33 +0200

author
Mike Becker <universe@uap-core.de>
date
Fri, 12 Jun 2026 15:32:33 +0200
changeset 137
43d1b3c33369
parent 136
1a84ee6b4bf0

fix memory leak when simulating real threats

src/chess/rules.c file | annotate | diff | comparison | revisions
--- a/src/chess/rules.c	Fri Jun 12 15:28:00 2026 +0200
+++ b/src/chess/rules.c	Fri Jun 12 15:32:33 2026 +0200
@@ -628,6 +628,7 @@
         }
 
         for (uint8_t i = 0 ; i < candidatecount ; i++) {
+            // TODO: check if we really need full-blown simulations here
             GameState simulation = gamestate_copy_sim(gamestate);
             Move simmove = candidates[i];
             apply_move(&simulation, &simmove);
@@ -638,6 +639,7 @@
                     threats[(*threatcount)++] = candidates[i];
                 }
             }
+            gamestate_cleanup(&simulation);
         }
         
         return result;

mercurial