fix: fixed textures leaks

This commit is contained in:
Theo Champion 2025-09-08 17:11:58 +02:00
parent 80150ce24d
commit f407f5b7ce
3 changed files with 41 additions and 3 deletions

View file

@ -6,7 +6,7 @@
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/08/18 13:05:31 by kcolin #+# #+# */
/* Updated: 2025/08/18 13:05:31 by kcolin ### ########.fr */
/* Updated: 2025/09/08 17:02:43 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,6 +14,15 @@
#include "../../mlx/mlx.h"
#include <stdlib.h>
void destroy_texture(t_cub3d_data *data, t_img_data *data_img)
{
if (data)
{
mlx_destroy_image(data->mlx, data_img->img);
}
free(data_img);
}
void destroy_textures(t_cub3d_data *data)
{
if (data->no_texture)
@ -45,3 +54,30 @@ void destroy_sprites(t_cub3d_data *data)
sprite++;
}
}
void destroy_hud_textures(t_cub3d_data *data)
{
int i;
i = 0;
while (i < 10)
{
destroy_texture(data, data->point_figures[i++]);
}
i = 0;
while (i < 10)
{
destroy_texture(data, data->round_figures[i++]);
}
i = 0;
while (i < 5)
{
destroy_texture(data, data->tally_marks[i++]);
}
i = 0;
while (i < 3)
{
destroy_texture(data, data->perk_logos[i++]);
}
destroy_texture(data, data->gun);
}