-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror_utils.c
55 lines (51 loc) · 1.59 KB
/
error_utils.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
/* ************************************************************************** */
/* */
/* :::::::: */
/* error_utils.c :+: :+: */
/* +:+ */
/* By: jvan-hal <[email protected]> +#+ */
/* +#+ */
/* Created: 2023/02/28 14:51:10 by jvan-hal #+# #+# */
/* Updated: 2023/02/28 14:54:55 by jvan-hal ######## odam.nl */
/* */
/* ************************************************************************** */
#include<errno.h>
#include<stdio.h>
#include<stdlib.h>
#include"fdf.h"
void del(void *node)
{
if (node)
free(node);
node = NULL;
}
int free_fdf(t_fdf *fdf)
{
if (fdf->texture[0] && fdf->texture[0]->pixels)
{
free(fdf->texture[0]->pixels);
free(fdf->texture[0]);
}
if (fdf->img[0])
mlx_delete_image(fdf->mlx, fdf->img[0]);
if (fdf->texture[1] && fdf->texture[1]->pixels)
{
free(fdf->texture[1]->pixels);
free(fdf->texture[1]);
}
if (fdf->img[1])
mlx_delete_image(fdf->mlx, fdf->img[1]);
if (fdf->mlx)
mlx_terminate(fdf->mlx);
if (fdf->coords)
ft_lstclear(&(fdf->coords), del);
free(fdf);
return (1);
}
void merror(t_fdf *fdf)
{
free_fdf(fdf);
errno = ENOMEM;
perror("Error");
exit(EXIT_FAILURE);
}