diff --git a/ST_grid.c b/ST_grid.c index 4970db89..2a1603ea 100644 --- a/ST_grid.c +++ b/ST_grid.c @@ -298,6 +298,7 @@ void save_sxw_memory(RealD * grid_roots_max, RealD* grid_rootsXphen, RealD* grid_roots_active, RealD* grid_roots_active_rel, RealD* grid_roots_active_sum, RealD* grid_phen, RealD* grid_prod_bmass, RealD* grid_prod_pctlive); +void _deallocate_memory(void); //void SXW_init( Bool init_SW ); @@ -643,6 +644,7 @@ void runGrid(void) printf("\routputting files took approximately %.2f seconds\n", ((double) (clock() - prog_Time) / CLOCKS_PER_SEC)); _free_grid_memory(); // free our allocated memory since we do not need it anymore + _deallocate_memory(); // sxw memory. /*if(UseProgressBar)*/printf("!\n"); } diff --git a/sxw.c b/sxw.c index 1984b850..bcbd4461 100644 --- a/sxw.c +++ b/sxw.c @@ -133,6 +133,7 @@ static void SXW_Reinit(void); void load_sxw_memory( RealD * grid_roots_max, RealD* grid_rootsXphen, RealD* grid_roots_active, RealD* grid_roots_active_rel, RealD* grid_roots_active_sum, RealD* grid_phen, RealD* grid_prod_bmass, RealD* grid_prod_pctlive ); void save_sxw_memory( RealD * grid_roots_max, RealD* grid_rootsXphen, RealD* grid_roots_active, RealD* grid_roots_active_rel, RealD* grid_roots_active_sum, RealD* grid_phen, RealD* grid_prod_bmass, RealD* grid_prod_pctlive ); void free_sxw_memory( void ); +void _deallocate_memory(void); /****************** Begin Function Code ********************/ /***********************************************************/ @@ -447,6 +448,15 @@ static void _allocate_memory(void){ transp_window->SoS_array = (RealF*) Mem_Calloc(transp_window->size, sizeof(RealF), "_allocate_memory: transp_window->SoS_array"); } +/* Deallocate any sxw local pointers. When running the non-gridded mode + * there is no need to call this since we only have one transp_window variable */ +void _deallocate_memory(void){ + Mem_Free(transp_window->ratios); + Mem_Free(transp_window->transp); + Mem_Free(transp_window->SoS_array); + Mem_Free(transp_window); +} + static void _read_files( void ) { /*======================================================*/ /* read list of input files. */