aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_raycasting.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-10 10:48:58 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-10 10:48:58 +0100
commitabd20a73b4733a1a8b845f6ff0817ed77e545173 (patch)
tree24e9630c1895c7ba17b0cff8b4061a0cab2cf46f /src/ft_raycasting.c
parentok now (diff)
download42-cub3d-abd20a73b4733a1a8b845f6ff0817ed77e545173.tar.gz
42-cub3d-abd20a73b4733a1a8b845f6ff0817ed77e545173.tar.bz2
42-cub3d-abd20a73b4733a1a8b845f6ff0817ed77e545173.tar.xz
42-cub3d-abd20a73b4733a1a8b845f6ff0817ed77e545173.tar.zst
42-cub3d-abd20a73b4733a1a8b845f6ff0817ed77e545173.zip
Freed multiple leaks
Diffstat (limited to 'src/ft_raycasting.c')
-rw-r--r--src/ft_raycasting.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c
index 3cbd368..baa71af 100644
--- a/src/ft_raycasting.c
+++ b/src/ft_raycasting.c
@@ -83,17 +83,16 @@ static void
void
ft_castray(t_cub *cl)
{
- uint16_t i;
- t_win *wl;
- float *dist_tab;
+ uint16_t i;
+ t_win *wl;
+ ft_memdel((void**)&cl->rlist.wall_dist_tab);
wl = &cl->wlist;
i = (wl->y_size / 2) + 1;
while (++i < wl->y_size)
ft_floor_cast(i, cl);
- if (!(dist_tab = malloc(sizeof(float) * cl->wlist.x_size)))
- return ;
- if (!(cl->rlist.wall_dist_tab = malloc(sizeof(float) * cl->wlist.x_size)))
+ if (!(cl->rlist.wall_dist_tab =
+ (float*)malloc(sizeof(float) * cl->wlist.x_size)))
return ;
i = 0;
while (i < wl->x_size)
@@ -102,8 +101,7 @@ void
ft_choose_tex(cl);
ft_calc_tex(cl);
ft_draw_verline(cl, i, cl->rlist.wall_t, cl->rlist.wall_b);
- dist_tab[i] = cl->rlist.wall_dist;
- cl->rlist.wall_dist_tab = dist_tab;
+ cl->rlist.wall_dist_tab[i] = cl->rlist.wall_dist;
i++;
}
}