diff --git a/src/cats/grids/cats_grid.c b/src/cats/grids/cats_grid.c index 48daf0cb70b21dfaf6c9d29407ea73eaf5737876..8814d975d2f21948b7fa680b0318318436a7baee 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; }