-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexit_no_leak.c
40 lines (38 loc) · 1.49 KB
/
exit_no_leak.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* exit_no_leak.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kakiba <kotto555555@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/31 18:46:04 by kakiba #+# #+# */
/* Updated: 2023/01/02 18:56:09 by kakiba ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
int exit_no_leak(t_fractol *fractol, int status)
{
if (fractol->img_param.img)
{
ft_printf("destroy_image\n");
mlx_destroy_image(fractol->mlx_server, fractol->img_param.img);
fractol->img_param.img = NULL;
}
if (fractol->window)
{
ft_printf("destroy_window\n");
mlx_destroy_window(fractol->mlx_server, fractol->window);
fractol->window = NULL;
}
if (fractol->mlx_server)
{
ft_printf("destroy_mlx_server\n");
mlx_destroy_display(fractol->mlx_server);
free (fractol->mlx_server);
fractol->mlx_server = NULL;
}
if (status == ERROR)
exit(EXIT_FAILURE);
else
exit(EXIT_SUCCESS);
}