-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclose.c
52 lines (46 loc) · 1.67 KB
/
close.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* close.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cado-car <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/03 23:08:35 by cado-car #+# #+# */
/* Updated: 2021/10/05 16:49:47 by cado-car ### ########.fr */
/* */
/* ************************************************************************** */
#include "../include/fdf.h"
static void close_coordinates(t_point **coordinates, int width);
void close_all(t_fdf *fdf, int exit_code)
{
close_coordinates(fdf->map->coordinates, fdf->map->max_x);
free(fdf->map);
mlx_destroy_image(fdf->mlx, fdf->image->image);
free(fdf->image);
free(fdf->cam);
mlx_destroy_window(fdf->mlx, fdf->win);
mlx_destroy_display(fdf->mlx);
free(fdf->mlx);
free(fdf);
error(exit_code);
}
void close_map(t_fdf *fdf, int exit_code)
{
close_coordinates(fdf->map->coordinates, fdf->map->max_x);
free(fdf->map);
mlx_destroy_window(fdf->mlx, fdf->win);
mlx_destroy_display(fdf->mlx);
free(fdf);
error(exit_code);
}
static void close_coordinates(t_point **coordinates, int width)
{
int i;
i = 0;
while (i < width)
{
free(coordinates[i]);
i++;
}
free(coordinates);
}