Skip to content

Commit

Permalink
(issue #728) added deallocation function to sxw.c
Browse files Browse the repository at this point in the history
This function will deallocate any dynamically allocated pointers in sxw.c.
  • Loading branch information
Chandler Haukap committed Apr 23, 2019
1 parent 5dc004d commit c3b8aa9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ST_grid.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 );


Expand Down Expand Up @@ -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");
}

Expand Down
10 changes: 10 additions & 0 deletions sxw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ********************/
/***********************************************************/
Expand Down Expand Up @@ -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. */
Expand Down

1 comment on commit c3b8aa9

@chaukap
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue #278 I accidentally put 728.

Please sign in to comment.