-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror_handling.c
More file actions
61 lines (55 loc) · 1.74 KB
/
error_handling.c
File metadata and controls
61 lines (55 loc) · 1.74 KB
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
60
61
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* error_handling.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kalshaer <kalshaer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/24 16:54:05 by kalshaer #+# #+# */
/* Updated: 2023/03/30 10:46:12 by kalshaer ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
void destory(char *s, t_mlx *mlx, int exit_code)
{
if (s)
ft_printf ("%s", s);
mlx_destroy_image(mlx->mlx, mlx->p.img);
mlx_destroy_image(mlx->mlx, mlx->w.img);
mlx_destroy_image(mlx->mlx, mlx->s.img);
mlx_destroy_image(mlx->mlx, mlx->c.img);
mlx_destroy_image(mlx->mlx, mlx->e.img);
mlx_destroy_image(mlx->mlx, mlx->sh.img);
mlx_clear_window(mlx->mlx, mlx->win);
mlx_destroy_window(mlx->mlx, mlx->win);
free_s(mlx->map);
exit (exit_code);
}
void errorh(char *s, char **split, char *ss)
{
ft_printf ("Error\n%s", s);
if (ss)
free (ss);
if (split)
free_s(split);
exit(0);
}
void errorh2(char *s, char **split, char **split2, char *ss)
{
ft_printf ("Error\n%s", s);
if (ss)
free (ss);
if (split)
free_s(split);
if (split2)
free_s(split2);
exit(0);
}
void free_s(char **s)
{
int i;
i = -1;
while (s[++i])
free(s[i]);
free(s);
}