cub3d/src/utils/frees.c

59 lines
1.6 KiB
C
Raw Normal View History

2025-06-25 18:08:19 +02:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* frees.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tchampio <tchampio@student.42lehavre. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/06/25 17:46:01 by tchampio #+# #+# */
2025-07-15 10:33:25 +02:00
/* Updated: 2025/07/15 10:26:48 by tchampio ### ########.fr */
2025-06-25 18:08:19 +02:00
/* */
/* ************************************************************************** */
#include "../../includes/cub3d_consts.h"
#include "../../includes/structs.h"
2025-07-15 10:33:25 +02:00
#include "../../mlx/mlx.h"
2025-06-25 18:08:19 +02:00
#include <stdlib.h>
void free_tab(char **tab)
{
int i;
if (!tab)
return ;
i = 0;
while (tab[i])
{
free(tab[i]);
i++;
}
free(tab);
}
void free_map(t_mapdata *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);
free(map);
}
2025-07-15 10:33:25 +02:00
int destroy(t_cub3d_data *data)
{
free_map(data->map);
if (data->mlx_win)
mlx_destroy_window(data->mlx, data->mlx_win);
if (data->mlx_data)
mlx_destroy_image(data->mlx, data->mlx_data->img);
free(data->mlx_data);
if (data->mlx)
mlx_destroy_display(data->mlx);
free(data->mlx);
exit(0);
return (0);
}