Skip to content

Commit

Permalink
Fixed memory leak in map. Added panic_free in clean_up function
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsunghao-C committed Aug 29, 2024
1 parent 492df5b commit 7f136de
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion includes/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: tsuchen <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/15 15:00:57 by jteissie #+# #+# */
/* Updated: 2024/08/29 11:29:05 by tsuchen ### ########.fr */
/* Updated: 2024/08/29 18:14:56 by tsuchen ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -43,6 +43,7 @@ typedef enum e_parse_status

int parse_map(t_data *data);
char **build_map(t_data *data);
void panic_free(char **array);
t_bool is_invalid_char(char c);
t_parse_status check_invalid_chars(char **map, size_t map_start);
void fill_whitespaces(char **map);
Expand Down
3 changes: 2 additions & 1 deletion srcs/cleanup.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: tsuchen <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/27 17:04:32 by jteissie #+# #+# */
/* Updated: 2024/08/29 15:50:27 by tsuchen ### ########.fr */
/* Updated: 2024/08/29 18:15:17 by tsuchen ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -43,5 +43,6 @@ int cleanup(t_data *data)
mlx_destroy_window(data->mlx, data->window);
mlx_destroy_display(data->mlx);
free(data->mlx);
panic_free(data->map);
exit(SUCCESS);
}
2 changes: 1 addition & 1 deletion srcs/game_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: tsuchen <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/27 17:03:43 by jteissie #+# #+# */
/* Updated: 2024/08/29 17:52:04 by tsuchen ### ########.fr */
/* Updated: 2024/08/29 18:17:15 by tsuchen ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down
2 changes: 1 addition & 1 deletion srcs/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: tsuchen <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/15 12:03:33 by tsuchen #+# #+# */
/* Updated: 2024/08/29 17:48:44 by tsuchen ### ########.fr */
/* Updated: 2024/08/29 18:10:59 by tsuchen ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down
6 changes: 3 additions & 3 deletions srcs/parser/build_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
/* ::: :::::::: */
/* build_map.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jteissie <jteissie@student.42.fr> +#+ +:+ +#+ */
/* By: tsuchen <tsuchen@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/16 16:51:48 by jteissie #+# #+# */
/* Updated: 2024/08/28 15:23:19 by jteissie ### ########.fr */
/* Updated: 2024/08/29 18:14:21 by tsuchen ### ########.fr */
/* */
/* ************************************************************************** */

#include "parser.h"

static void panic_free(char **array)
void panic_free(char **array)
{
u_int32_t i;

Expand Down

0 comments on commit 7f136de

Please sign in to comment.