Skip to content

Commit

Permalink
fix: free instead of delete for malloc'd mem
Browse files Browse the repository at this point in the history
  • Loading branch information
hellkite500 committed Jun 13, 2024
1 parent 7e60492 commit 2288e90
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/bmi_lgar.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ Initialize (std::string config_file)
*/
void BmiLGAR::realloc_soil(){
if(state->lgar_bmi_params.soil_depth_wetting_fronts != nullptr)
delete state->lgar_bmi_params.soil_depth_wetting_fronts;
free(state->lgar_bmi_params.soil_depth_wetting_fronts);
if(state->lgar_bmi_params.soil_moisture_wetting_fronts != nullptr)
delete state->lgar_bmi_params.soil_moisture_wetting_fronts;
free(state->lgar_bmi_params.soil_moisture_wetting_fronts);

state->lgar_bmi_params.soil_depth_wetting_fronts = new double[state->lgar_bmi_params.num_wetting_fronts];
state->lgar_bmi_params.soil_moisture_wetting_fronts = new double[state->lgar_bmi_params.num_wetting_fronts];
Expand Down
4 changes: 2 additions & 2 deletions src/lgar.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1138,8 +1138,8 @@ extern void lgar_move_wetting_fronts(double timestep_h, double *volin_cm, int wf
delta_thetas, delta_thickness, soil_type, soil_properties);
actual_ET_demand = *AET_demand_cm;
//done with delta_thetas and delta_thickness, cleanup memory
delete delta_thetas;
delete delta_thickness;
free(delta_thetas);
free(delta_thickness);
current->theta = fmax(theta_r, fmin(theta_new, theta_e));

double Se = calc_Se_from_theta(current->theta,theta_e,theta_r);
Expand Down

0 comments on commit 2288e90

Please sign in to comment.