diff options
author | Oliver Schinagl <oliver@schinagl.nl> | 2008-01-10 12:03:07 (GMT) |
---|---|---|
committer | Oliver Schinagl <oliver@schinagl.nl> | 2008-01-10 12:03:07 (GMT) |
commit | 148047d7dc230cda271b12a4f7388917038b6364 (patch) | |
tree | d5f1544bb550335134853e6f11f6529e9cba74fd /Smoke/fluids.c | |
parent | cac2c65e1b8ae9d407a5cffafbac06c0803753ac (diff) | |
download | 2iv35-148047d7dc230cda271b12a4f7388917038b6364.zip 2iv35-148047d7dc230cda271b12a4f7388917038b6364.tar.gz 2iv35-148047d7dc230cda271b12a4f7388917038b6364.tar.bz2 |
fixed memleak etc
Diffstat (limited to 'Smoke/fluids.c')
-rw-r--r-- | Smoke/fluids.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/Smoke/fluids.c b/Smoke/fluids.c index 2a59ef1..cce2c38 100644 --- a/Smoke/fluids.c +++ b/Smoke/fluids.c @@ -9,6 +9,7 @@ #include <math.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <rfftw.h> @@ -76,11 +77,11 @@ void fluids_init_simulation(int n, struct vis_data_arrays *vis_data) plan_cr = rfftw2d_create_plan(n, n, FFTW_COMPLEX_TO_REAL, FFTW_IN_PLACE); height_array = (fftw_real*) malloc(dim2); - normal_array = (struct point*) malloc(dim2); + normal_array = (struct point*) malloc(dim2 *sizeof(struct point *)); for (i = 0; i < HISTORY_SIZE; i++) { - vis_data->history[i] = (fftw_real*)malloc(dim1); + vis_data->history[i] = (fftw_real *)malloc(dim1); } fluids_reset_simulation(); @@ -413,14 +414,8 @@ void add_history_frame(int dataset, struct vis_data_arrays *vis_data) if (dataset != DATASET_HIST) { frame = get_frame(vis_data, dataset); -// printf("hisdex: %d\n", hisdex); - - // if (hisdex) { - memcpy(vis_data->history[hisdex], frame, DIM * 2 * (DIM / 2) * sizeof(fftw_real)); - // } else { - // memcpy(vis_data->history[0], frame, DIM * 2 * (DIM / 2) * sizeof(fftw_real)); - // memcpy(vis_data->history[hisdex], vis_data->history[0], DIM * 2 * (DIM / 2) * sizeof(fftw_real)); - // } + + memcpy(vis_data->history[hisdex], frame, DIM * 2 * (DIM / 2 + 1) * sizeof(fftw_real)); hisdex = (hisdex >= HISTORY_SIZE -1) ? 0 : hisdex +1; } } @@ -503,7 +498,6 @@ void fluids_calculate_one_simulation_step(struct vis_data_arrays *vis_data) heightplots_set_frame(vis_data->height); normals_set_frame(vis_data->normals); - streamlines_set_history(vis_data->history); } //------ VISUALIZATION CODE STARTS HERE ----------------------------------------------------------------- |