-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed leak issue in map_list. Ready to Merge
- Loading branch information
1 parent
01e890a
commit 2664a23
Showing
5 changed files
with
8 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: tsuchen <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/08/15 00:19:44 by tsuchen #+# #+# */ | ||
/* Updated: 2024/08/30 11:02:01 by tsuchen ### ########.fr */ | ||
/* Updated: 2024/08/30 14:08:32 by tsuchen ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -104,7 +104,6 @@ typedef struct s_data | |
char *map_path; | ||
int map_fd; | ||
size_t map_bound; | ||
// size_t map_start; | ||
char **map; | ||
void *mlx; | ||
void *window; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: tsuchen <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/08/27 17:03:43 by jteissie #+# #+# */ | ||
/* Updated: 2024/08/29 19:06:27 by tsuchen ### ########.fr */ | ||
/* Updated: 2024/08/30 14:08:48 by tsuchen ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -44,8 +44,8 @@ int game_init(t_data *data) | |
} | ||
if (load_assets(data) == PANIC) | ||
{ | ||
// cleanup(data); | ||
// return (PANIC); | ||
cleanup(data); | ||
return (PANIC); | ||
} | ||
data->image.img = mlx_new_image(data->mlx, WIDTH, HEIGHT); | ||
data->image.addr = mlx_get_data_addr(data->image.img, &data->image.bpp, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: tsuchen <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/08/15 12:03:33 by tsuchen #+# #+# */ | ||
/* Updated: 2024/08/30 11:48:49 by tsuchen ### ########.fr */ | ||
/* Updated: 2024/08/30 14:09:06 by tsuchen ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -77,7 +77,6 @@ int main(int ac, char *av[]) | |
return (EXIT_FAILURE); | ||
if (parse_map(&data) == PANIC) | ||
return (EXIT_FAILURE); | ||
// print_data(&data); | ||
if (game_init(&data) == PANIC) | ||
return (EXIT_FAILURE); | ||
start_game(&data); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: tsuchen <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/08/16 16:51:48 by jteissie #+# #+# */ | ||
/* Updated: 2024/08/30 12:00:04 by tsuchen ### ########.fr */ | ||
/* Updated: 2024/08/30 14:07:33 by tsuchen ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -25,29 +25,6 @@ void panic_free(char **array) | |
free(array); | ||
} | ||
|
||
// static size_t get_map_size(char *path) | ||
// { | ||
// int fd; | ||
// size_t line_nb; | ||
// char *gnl_buff; | ||
|
||
// fd = open(path, O_RDONLY); | ||
// if (fd < 0) | ||
// return (0); | ||
// gnl_buff = get_next_line(fd); | ||
// if (!gnl_buff) | ||
// return (0); | ||
// line_nb = 1; | ||
// while (gnl_buff) | ||
// { | ||
// free(gnl_buff); | ||
// gnl_buff = get_next_line(fd); | ||
// line_nb++; | ||
// } | ||
// close(fd); | ||
// return (line_nb); | ||
// } | ||
|
||
static t_list *read_map_file(char *line, t_data *data) | ||
{ | ||
t_list *map_list; | ||
|
@@ -65,7 +42,7 @@ static t_list *read_map_file(char *line, t_data *data) | |
ft_lstclear(&map_list, free); | ||
return (NULL); | ||
} | ||
ft_lstadd_back(&map_list, ft_lstnew(line)); | ||
ft_lstadd_back(&map_list, new_node); | ||
} | ||
else | ||
free(line); | ||
|
@@ -74,32 +51,6 @@ static t_list *read_map_file(char *line, t_data *data) | |
return (map_list); | ||
} | ||
|
||
// static char **read_map_file(size_t size, char *line, t_data *data) | ||
// { | ||
// size_t index; | ||
// char **map; | ||
|
||
// index = 0; | ||
// map = ft_calloc(size + 1, sizeof(char *)); | ||
// if (!map) | ||
// return (NULL); | ||
// while (line) | ||
// { | ||
// map[index] = ft_strdup(line); | ||
// if (!map[index]) | ||
// { | ||
// free(line); | ||
// panic_free(map); | ||
// return (NULL); | ||
// } | ||
// free(line); | ||
// line = get_next_line(data->map_fd); | ||
// index++; | ||
// } | ||
// map[index] = NULL; | ||
// return (map); | ||
// } | ||
|
||
char **build_map(t_data *data, char *line) | ||
{ | ||
t_list *map_list; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: tsuchen <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/08/15 12:12:00 by tsuchen #+# #+# */ | ||
/* Updated: 2024/08/30 11:46:42by tsuchen ### ########.fr */ | ||
/* Updated: 2024/08/30 14:09:41 by tsuchen ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -98,7 +98,6 @@ int parse_map(t_data *data) | |
close(data->map_fd); | ||
if (!data->map) | ||
return (PANIC); | ||
// print_parsed_map(data); | ||
if (verify_map(data->map, data) == MAP_ERR) | ||
{ | ||
ft_putstr_fd("Error\n", STDERR_FILENO); | ||
|