-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsl_memory.c
81 lines (73 loc) · 2.26 KB
/
sl_memory.c
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* sl_memory.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: julmuntz <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/01 13:59:55 by julmuntz #+# #+# */
/* Updated: 2022/09/14 23:15:27 by julmuntz ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
void sl_free_image(t_data *data)
{
if (data->img_s)
mlx_destroy_image(data->mlx, data->img_s);
if (data->img_0)
mlx_destroy_image(data->mlx, data->img_0);
if (data->img_1)
mlx_destroy_image(data->mlx, data->img_1);
if (data->img_e)
mlx_destroy_image(data->mlx, data->img_e);
if (data->img_z)
mlx_destroy_image(data->mlx, data->img_z);
if (data->img_c)
mlx_destroy_image(data->mlx, data->img_c);
if (data->img_p)
mlx_destroy_image(data->mlx, data->img_p);
if (data->img_u_p)
mlx_destroy_image(data->mlx, data->img_u_p);
if (data->img_l_p)
mlx_destroy_image(data->mlx, data->img_l_p);
if (data->img_d_p)
mlx_destroy_image(data->mlx, data->img_d_p);
if (data->img_r_p)
mlx_destroy_image(data->mlx, data->img_r_p);
if (data->img_dig)
mlx_destroy_image(data->mlx, data->img_dig);
}
void sl_free_map(t_data *data)
{
int i;
i = 0;
while (data->map[i])
free(data->map[i++]);
free(data->map);
}
void sl_free_mapcpy(t_data *data)
{
int i;
i = 0;
while (data->map_copy[i])
free(data->map_copy[i++]);
free(data->map_copy);
}
void sl_free_mapall(t_data *data)
{
sl_free_map(data);
sl_free_mapcpy(data);
}
void sl_free(t_data *data)
{
if (data)
{
sl_free_map(data);
sl_free_image(data);
mlx_clear_window(data->mlx, data->window);
mlx_destroy_window(data->mlx, data->window);
data->window = 0;
mlx_destroy_display(data->mlx);
free(data->mlx);
}
}