diff --git a/config.c b/config.c index f0a65a8..338657e 100644 --- a/config.c +++ b/config.c @@ -6,7 +6,7 @@ /* By: yantoine +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/14 01:41:17 by yantoine #+# #+# */ -/* Updated: 2025/02/25 02:50:49 by yantoine ### ########.fr */ +/* Updated: 2025/02/25 15:41:28 by yantoine ### ########.fr */ /* */ /* ************************************************************************** */ @@ -38,7 +38,8 @@ static inline t_scene parsing_line(char *line, t_scene scene) t_scene load_config(const char *filename) { int fd; - char *line; + size_t len; + char line[999] = {0}; t_scene scene; scene = create_scene(); @@ -51,11 +52,12 @@ t_scene load_config(const char *filename) scene.fd_if_exit = fd; while (1) { - line = get_next_line(fd); - if (!line) + len = read(fd, line, 999); + if (!len) break ; + if (len > 998) + exit(1); scene = parsing_line(line, scene); - free(line); } return (scene); } diff --git a/main.c b/main.c index 6ad22b9..b5f7337 100644 --- a/main.c +++ b/main.c @@ -6,7 +6,7 @@ /* By: yantoine +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/17 19:54:03 by yantoine #+# #+# */ -/* Updated: 2025/02/25 02:52:11 by yantoine ### ########.fr */ +/* Updated: 2025/02/25 14:52:51 by yantoine ### ########.fr */ /* */ /* ************************************************************************** */ @@ -62,18 +62,18 @@ static int check_number(t_scene scene) int main(int argc, char **argv) { - t_app *app; + t_app app; ft_bzero(&app, sizeof(t_app)); - init_app_config(app, argc, argv); - if (!check_number(app->scene) || \ - app->scene.num_camera == 0 \ - || init_mlx_and_image(app)) + init_app_config(&app, argc, argv); + if (!check_number(app.scene) || \ + app.scene.num_camera == 0 \ + || init_mlx_and_image(&app)) return (1); - update_camera(app); - render_scene(app); - mlx_hook(app.win, 2, 1L << 0, key_press, app); - mlx_hook(app.win, 17, 0, handle_close, app); + update_camera(&app); + render_scene(&app); + mlx_hook(app.win, 2, 1L << 0, key_press, &app); + mlx_hook(app.win, 17, 0, handle_close, &app); mlx_loop(app.mlx); return (0); } diff --git a/miniRT b/miniRT index 478004e..26f01ee 100755 Binary files a/miniRT and b/miniRT differ diff --git a/parsing_utils.c b/parsing_utils.c index 29bbc64..037ad3c 100644 --- a/parsing_utils.c +++ b/parsing_utils.c @@ -6,7 +6,7 @@ /* By: yantoine +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/14 20:23:21 by yantoine #+# #+# */ -/* Updated: 2025/02/25 02:46:24 by yantoine ### ########.fr */ +/* Updated: 2025/02/25 15:30:42 by yantoine ### ########.fr */ /* */ /* ************************************************************************** */ @@ -23,7 +23,6 @@ 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); } diff --git a/peripherique.c b/peripherique.c index b81e1c2..3768f74 100644 --- a/peripherique.c +++ b/peripherique.c @@ -6,7 +6,7 @@ /* By: yantoine +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/17 19:22:27 by yantoine #+# #+# */ -/* Updated: 2025/02/25 00:15:35 by yantoine ### ########.fr */ +/* Updated: 2025/02/25 15:38:46 by yantoine ### ########.fr */ /* */ /* ************************************************************************** */ @@ -29,7 +29,7 @@ int key_press(int keycode, t_app *app) int handle_close(void *param) { - t_app *app; + t_app *app; app = (t_app *)param; mlx_destroy_image(app->mlx, app->img);