regler leak dans exit

This commit is contained in:
H3XploR
2025-02-25 19:09:14 +01:00
parent 029c8dcc70
commit 5a7424600d
7 changed files with 116 additions and 9 deletions
+34 -3
View File
@@ -6,7 +6,7 @@
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/14 01:41:17 by yantoine #+# #+# */
/* Updated: 2025/02/25 17:52:55 by yantoine ### ########.fr */
/* Updated: 2025/02/25 19:05:30 by yantoine ### ########.fr */
/* */
/* ************************************************************************** */
@@ -34,10 +34,39 @@ static inline t_scene parsing_line(char *line, t_scene scene)
return (scene);
}
static char **get_all_file(int fd)
{
char *join;
char *line;
char *data;
char **splited;
int first;
first = 1;
line = NULL;
data = ft_calloc(1, 1);
while (1)
{
if (!first)
data = join;
line = get_next_line(fd);
if (!line)
break ;
join = ft_strjoin(data, line);
free(line);
free(data);
first = 0;
}
splited = ft_split(join, '\n');
free(data);
return (splited);
}
// ----- Parsing du fichier de configuration -----
t_scene load_config(const char *filename)
{
int fd;
int i;
char *line;
t_scene scene;
@@ -49,9 +78,11 @@ t_scene load_config(const char *filename)
return (scene);
}
scene.fd_if_exit = fd;
while (1)
scene.all_file = get_all_file(fd);
i = -1;
while (scene.all_file[++i])
{
line = get_next_line(fd);
line = scene.all_file[i];
if (!line)
break ;
scene = parsing_line(line, scene);