This commit is contained in:
H3XploR
2025-02-25 17:53:58 +01:00
parent 6b5b525145
commit 029c8dcc70
3 changed files with 7 additions and 9 deletions
+5 -8
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 15:42:48 by yantoine ### ########.fr */
/* Updated: 2025/02/25 17:52:55 by yantoine ### ########.fr */
/* */
/* ************************************************************************** */
@@ -38,11 +38,9 @@ static inline t_scene parsing_line(char *line, t_scene scene)
t_scene load_config(const char *filename)
{
int fd;
size_t len;
char line[999];
char *line;
t_scene scene;
ft_bzero(line, 999);
scene = create_scene();
fd = open(filename, O_RDONLY);
if (fd <= 0 || !have_extension(filename))
@@ -53,12 +51,11 @@ t_scene load_config(const char *filename)
scene.fd_if_exit = fd;
while (1)
{
len = read(fd, line, 999);
if (!len)
line = get_next_line(fd);
if (!line)
break ;
if (len > 998)
exit(1);
scene = parsing_line(line, scene);
free(line);
}
return (scene);
}
BIN
View File
Binary file not shown.
+2 -1
View File
@@ -6,7 +6,7 @@
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/14 20:23:21 by yantoine #+# #+# */
/* Updated: 2025/02/25 15:30:42 by yantoine ### ########.fr */
/* Updated: 2025/02/25 17:42:45 by yantoine ### ########.fr */
/* */
/* ************************************************************************** */
@@ -23,6 +23,7 @@ char **get_tokens_secure(t_scene scene, const int numObject,
{
ft_free_array(tokens);
ft_putendl_fd("error", 2);
free(scene.line_if_exit);
close(scene.fd_if_exit);
exit(1);
}