mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 09:58:09 +01:00
fix: fixed textures leaks
This commit is contained in:
parent
80150ce24d
commit
f407f5b7ce
3 changed files with 41 additions and 3 deletions
|
|
@ -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/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 "../../mlx/mlx.h"
|
||||||
#include <stdlib.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)
|
void destroy_textures(t_cub3d_data *data)
|
||||||
{
|
{
|
||||||
if (data->no_texture)
|
if (data->no_texture)
|
||||||
|
|
@ -45,3 +54,30 @@ void destroy_sprites(t_cub3d_data *data)
|
||||||
sprite++;
|
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);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */
|
/* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/08/11 12:07:48 by tchampio #+# #+# */
|
/* Created: 2025/08/11 12:07:48 by tchampio #+# #+# */
|
||||||
/* Updated: 2025/08/11 12:10:21 by tchampio ### ########.fr */
|
/* Updated: 2025/09/08 14:15:25 by tchampio ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -17,5 +17,6 @@
|
||||||
|
|
||||||
void destroy_textures(t_cub3d_data *data);
|
void destroy_textures(t_cub3d_data *data);
|
||||||
void destroy_sprites(t_cub3d_data *data);
|
void destroy_sprites(t_cub3d_data *data);
|
||||||
|
void destroy_hud_textures(t_cub3d_data *data);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/07/17 13:59:27 by kcolin #+# #+# */
|
/* Created: 2025/07/17 13:59:27 by kcolin #+# #+# */
|
||||||
/* Updated: 2025/08/12 15:38:45 by tchampio ### ########.fr */
|
/* Updated: 2025/09/08 14:15:58 by tchampio ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -67,6 +67,7 @@ int destroy(t_cub3d_data *data, int exit_code)
|
||||||
if (data->img_data)
|
if (data->img_data)
|
||||||
mlx_destroy_image(data->mlx, data->img_data->img);
|
mlx_destroy_image(data->mlx, data->img_data->img);
|
||||||
destroy_textures(data);
|
destroy_textures(data);
|
||||||
|
destroy_hud_textures(data);
|
||||||
destroy_sprites(data);
|
destroy_sprites(data);
|
||||||
free(data->img_data);
|
free(data->img_data);
|
||||||
if (data->mlx)
|
if (data->mlx)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue