From e2d66d64272973e7ec14180637e16e55a3a0c6aa Mon Sep 17 00:00:00 2001
From: Andreas Gattringer <andreas.gattringer@univie.ac.at>
Date: Tue, 18 Jul 2023 15:16:00 +0200
Subject: [PATCH] fully free seed bank at cleanup

---
 src/cats/grids/cats_grid.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/cats/grids/cats_grid.c b/src/cats/grids/cats_grid.c
index 48daf0c..8814d97 100644
--- a/src/cats/grids/cats_grid.c
+++ b/src/cats/grids/cats_grid.c
@@ -255,6 +255,7 @@ void cleanup_grid_seeds_and_juveniles(struct cats_grid *grid)
                         for (cats_dt_coord col = 0; col < grid->dimension.cols; col++) {
                                 destroy_seed_structure(grid, row, col);
                         }
+                        free(grid->seed_bank[row]);
                 }
         }
 
@@ -265,14 +266,22 @@ void cleanup_grid_seeds_and_juveniles(struct cats_grid *grid)
                                 destroy_juveniles(grid, row, col);
                         }
 
-                        free(grid->seed_bank[row]);
+                        free(grid->juveniles[row]);
+                }
+       }
+
+        if (grid->seeds_produced) {
+                for (cats_dt_coord row = 0; row < grid->dimension.rows; row++) {
+                        free(grid->seeds_produced[row]);
                 }
         }
 
         free(grid->seed_bank);
         free(grid->juveniles);
+        free(grid->seeds_produced);
         grid->juveniles = NULL;
         grid->seed_bank = NULL;
+        grid->seeds_produced = NULL;
 }
 
 
-- 
GitLab