-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfree_stuff.c
59 lines (52 loc) · 1.59 KB
/
free_stuff.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* free_stuff.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: phelebra <xhelp00@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/06/10 16:50:14 by jbartosi #+# #+# */
/* Updated: 2023/10/16 16:05:02 by phelebra ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
int free_sprites(t_box *box)
{
t_sprite *next;
next = box->sprites;
if (!next)
return (0);
while (next)
{
next = box->sprites->next;
free(box->sprites->data);
free(box->sprites);
box->sprites = next;
}
return (0);
}
int free_map(t_box *box)
{
int i;
i = 0;
while (box->map[i])
free(box->map[i++]);
free(box->map);
return (0);
}
void free_stuff(t_box *box)
{
int i;
i = -1;
while (++i < 50)
mlx_destroy_image(box->mlx, box->textures[i].img);
free(box->textures);
free_sprites(box);
free_map(box);
mlx_destroy_image(box->mlx, box->image.img);
mlx_destroy_window(box->mlx, box->win);
mlx_destroy_display(box->mlx);
free(box->mlx);
free(box->info.ray);
free(box->info.zbuffer);
}