-
Notifications
You must be signed in to change notification settings - Fork 0
/
error_handling.c
45 lines (41 loc) · 1.42 KB
/
error_handling.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* error_handling.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: abdsalah <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/29 00:43:43 by abdsalah #+# #+# */
/* Updated: 2025/01/03 10:08:12 by abdsalah ### ########.fr */
/* */
/* ************************************************************************** */
#include "fract_ol.h"
int ft_close_window(t_graphics *graphics)
{
ft_free_graphics(graphics);
exit(0);
}
void ft_error_exit(char *message)
{
ft_putendl_fd(message, 2);
exit(EXIT_FAILURE);
}
void ft_free_graphics(t_graphics *graphics)
{
if (graphics->img)
{
mlx_destroy_image(graphics->mlx, graphics->img);
graphics->img = NULL;
}
if (graphics->win)
{
mlx_destroy_window(graphics->mlx, graphics->win);
graphics->win = NULL;
}
if (graphics->mlx)
{
mlx_destroy_display(graphics->mlx);
free(graphics->mlx);
graphics->mlx = NULL;
}
}