fix: fixed texture leakage

This commit is contained in:
Theo Champion 2025-09-10 15:19:30 +02:00
parent ecb99e4840
commit 87c0a8a991

View file

@ -6,7 +6,7 @@
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */ /* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/08/18 13:05:31 by kcolin #+# #+# */ /* Created: 2025/08/18 13:05:31 by kcolin #+# #+# */
/* Updated: 2025/09/08 17:02:43 by tchampio ### ########.fr */ /* Updated: 2025/09/10 15:18:58 by tchampio ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -25,6 +25,7 @@ void destroy_texture(t_cub3d_data *data, t_img_data *data_img)
void destroy_textures(t_cub3d_data *data) void destroy_textures(t_cub3d_data *data)
{ {
int i;
if (data->no_texture) if (data->no_texture)
mlx_destroy_image(data->mlx, data->no_texture->img); mlx_destroy_image(data->mlx, data->no_texture->img);
free(data->no_texture); free(data->no_texture);
@ -37,6 +38,9 @@ void destroy_textures(t_cub3d_data *data)
if (data->we_texture) if (data->we_texture)
mlx_destroy_image(data->mlx, data->we_texture->img); mlx_destroy_image(data->mlx, data->we_texture->img);
free(data->we_texture); free(data->we_texture);
i = 0;
while (i < 7)
destroy_texture(data, data->barricades_texture[i++]);
} }
void destroy_sprites(t_cub3d_data *data) void destroy_sprites(t_cub3d_data *data)