stardis-solver

Solve coupled heat transfers
git clone git://git.meso-star.fr/stardis-solver.git
Log | Files | Refs | README | LICENSE

commit 594f62057b6b82ae1fb0bc46099fd1a0a064bb0b
parent b1eb2d77703a47936c389217f0fb56fa3a9cef4d
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Mon, 29 Jun 2020 16:56:59 +0200

Fix memory leaks in sdis_solve_camera

Diffstat:
Msrc/sdis_solve.c | 6+++++-
Msrc/test_sdis_solve_camera.c | 10+++++++++-
2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/sdis_solve.c b/src/sdis_solve.c @@ -79,6 +79,7 @@ solve_pixel { struct accum acc_temp = ACCUM_NULL; struct accum acc_time = ACCUM_NULL; + struct sdis_heat_path* pheat_path = NULL; size_t irealisation; res_T res = RES_OK; ASSERT(scn && mdm && rng && cam && ipix && nrealisations && Tref >= 0); @@ -91,7 +92,6 @@ solve_pixel double ray_pos[3]; double ray_dir[3]; double w = 0; - struct sdis_heat_path* pheat_path = NULL; struct sdis_heat_path heat_path; double time; res_T res_simul = RES_OK; @@ -131,9 +131,11 @@ solve_pixel /* Check if the path must be saved regarding the register_paths mask */ if(!(register_paths & (int)pheat_path->status)) { heat_path_release(pheat_path); + pheat_path = NULL; } else { /* Register the sampled path */ res = estimator_add_and_release_heat_path(estimator, pheat_path); if(res != RES_OK) goto error; + pheat_path = NULL; } } @@ -155,6 +157,7 @@ solve_pixel estimator_setup_realisation_time(estimator, acc_time.sum, acc_time.sum2); exit: + if(pheat_path) heat_path_release(pheat_path); return res; error: goto exit; @@ -503,6 +506,7 @@ exit: if(out_buf) *out_buf = buf; return (res_T)res; error: + if(buf) SDIS(estimator_buffer_ref_put(buf)); goto exit; } diff --git a/src/test_sdis_solve_camera.c b/src/test_sdis_solve_camera.c @@ -695,9 +695,17 @@ main(int argc, char** argv) /* Write the image */ dump_image(buf); + OK(sdis_estimator_buffer_ref_put(buf)); + + pfluid_param = sdis_data_get(sdis_medium_get_data(fluid1)); + pfluid_param->temperature = UNKOWN_TEMPERATURE; + + /* Check simulation error handling */ + BA(sdis_solve_camera(scn, &solve_args, &buf)); + solve_args.register_paths = SDIS_HEAT_PATH_ALL; + BA(sdis_solve_camera(scn, &solve_args, &buf)); /* Release memory */ - OK(sdis_estimator_buffer_ref_put(buf)); OK(sdis_medium_ref_put(solid)); OK(sdis_medium_ref_put(fluid0)); OK(sdis_medium_ref_put(fluid1));