-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclean_exit.c
More file actions
58 lines (54 loc) · 1.95 KB
/
Copy pathclean_exit.c
File metadata and controls
58 lines (54 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* clean_exit.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: topiana- <topiana-@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/09 12:02:14 by topiana- #+# #+# */
/* Updated: 2025/06/23 12:49:37 by topiana- ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3D.h"
#include <stdlib.h>
int clean_exit(t_mlx *mlx, int exit_code);
static void destroy_wall_data(t_mlx *mlx)
{
if (mlx->map.walls[NO].img_ptr)
mlx_destroy_image(mlx->mlx, mlx->map.walls[NO].img_ptr);
if (mlx->map.walls[SO].img_ptr)
mlx_destroy_image(mlx->mlx, mlx->map.walls[SO].img_ptr);
if (mlx->map.walls[EA].img_ptr)
mlx_destroy_image(mlx->mlx, mlx->map.walls[EA].img_ptr);
if (mlx->map.walls[WE].img_ptr)
mlx_destroy_image(mlx->mlx, mlx->map.walls[WE].img_ptr);
if (mlx->map.no_wall)
free(mlx->map.no_wall);
if (mlx->map.so_wall)
free(mlx->map.so_wall);
if (mlx->map.we_wall)
free(mlx->map.we_wall);
if (mlx->map.ea_wall)
free(mlx->map.ea_wall);
}
int clean_exit(t_mlx *mlx, int exit_code)
{
destroy_wall_data(mlx);
if (mlx->mlx)
{
if (mlx->img->img_ptr)
mlx_destroy_image(mlx->mlx, mlx->img->img_ptr);
if (mlx->win)
{
mlx_destroy_window(mlx->mlx, mlx->win);
mlx->win = NULL;
}
if (__LINUX__)
mlx_destroy_display(mlx->mlx);
free(mlx->mlx);
}
if (mlx->map.mtx)
free_mtx((void **)mlx->map.mtx);
exit(exit_code);
return (0);
}