Added frees for the mapdata structure

This commit is contained in:
Theo Champion 2025-06-20 23:59:27 +02:00
parent 9ba3771ebf
commit 977385492b

View file

@ -6,7 +6,7 @@
/* By: tchampio <tchampio@student.42lehavre. +#+ +:+ +#+ */ /* By: tchampio <tchampio@student.42lehavre. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/06 13:16:11 by tchampio #+# #+# */ /* Created: 2025/05/06 13:16:11 by tchampio #+# #+# */
/* Updated: 2025/06/16 16:12:50 by tchampio ### ########.fr */ /* Updated: 2025/06/20 23:58:56 by tchampio ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -36,9 +36,29 @@ void my_mlx_pixel_put(t_mlx_data *data, int x, int y, int color)
*(unsigned int*)dst = color; *(unsigned int*)dst = color;
} }
void free_tab(char **tab)
{
int i;
if (!tab)
return ;
i = 0;
while (tab[i])
{
free(tab[i]);
i++;
}
free(tab);
}
int destroy(t_mapdata *map) int destroy(t_mapdata *map)
{ {
(void)map; free_tab(map->map);
free_tab(map->mapflood);
free(map->EA_texture);
free(map->NO_texture);
free(map->SO_texture);
free(map->WE_texture);
free(map->filename);
exit(0); exit(0);
return 0; return 0;
} }