g trouver erreur, juste compter les ligne sans mallocet exit en cas erreur (pour eviter le vieux leak de gnl

This commit is contained in:
Yannis Antoine
2025-03-05 17:57:45 +01:00
parent 01b852210b
commit fb27cad32e
2 changed files with 100012 additions and 5 deletions
+12 -5
View File
@@ -6,7 +6,7 @@
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */ /* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/14 01:41:17 by yantoine #+# #+# */ /* Created: 2025/02/14 01:41:17 by yantoine #+# #+# */
/* Updated: 2025/03/05 16:27:44 by yantoine ### ########.fr */ /* Updated: 2025/03/05 17:54:38 by yantoine ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -40,14 +40,21 @@ static char **get_all_file(int fd)
char *line; char *line;
char *data; char *data;
char **splited; char **splited;
int first; int count;
first = 1; count = 0;
line = NULL; line = NULL;
data = ft_calloc(1, 1); data = ft_calloc(1, 1);
while (1) while (1)
{ {
if (!first) if (count > MAX_SPHERES + MAX_PLANES + MAX_CYLINDERS + MAX_LIGHTS + MAX_AMBIENT + MAX_CAMERA)
{
free(join);
ft_putstr_fd("erreur: max element reached\n", 2);
close(fd);
exit(1);
}
if (count != 0)
data = join; data = join;
line = get_next_line(fd); line = get_next_line(fd);
if (!line) if (!line)
@@ -55,7 +62,7 @@ static char **get_all_file(int fd)
join = ft_strjoin(data, line); join = ft_strjoin(data, line);
free(line); free(line);
free(data); free(data);
first = 0; count++;
} }
splited = ft_split(join, '\n'); splited = ft_split(join, '\n');
free(data); free(data);
File diff suppressed because it is too large Load Diff