no segfault by not enclosed map etc

This commit is contained in:
whaffman 2025-05-29 12:07:23 +02:00
parent d8b93222c0
commit c40c3bb9d6
4 changed files with 26 additions and 23 deletions

View File

@ -6,7 +6,7 @@
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/04/23 12:18:31 by whaffman #+# #+# */
/* Updated: 2025/04/23 12:20:25 by whaffman ######## odam.nl */
/* Updated: 2025/05/29 11:57:45 by whaffman ######## odam.nl */
/* */
/* ************************************************************************** */
@ -21,6 +21,7 @@ t_tile **create_grid(int width, int height)
grid = malloc(sizeof(t_tile *) * height);
if (!grid)
return (NULL);
ft_memset(grid, 0, sizeof(t_tile *) * height);
i = 0;
while (i < height)
{

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* grid_free.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/23 12:20:38 by whaffman #+# #+# */
/* Updated: 2025/05/28 13:09:39 by qmennen ### ########.fr */
/* :::::::: */
/* grid_free.c :+: :+: */
/* +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/04/23 12:20:38 by whaffman #+# #+# */
/* Updated: 2025/05/29 11:52:35 by whaffman ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* map_create.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/23 12:21:13 by whaffman #+# #+# */
/* Updated: 2025/05/28 13:20:00 by qmennen ### ########.fr */
/* :::::::: */
/* map_create.c :+: :+: */
/* +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/04/23 12:21:13 by whaffman #+# #+# */
/* Updated: 2025/05/29 12:04:12 by whaffman ######## odam.nl */
/* */
/* ************************************************************************** */
@ -57,7 +57,7 @@ static int map_validate_and_finalize(t_game **game, t_tile **grid)
{
ft_putendl_fd("Map is not enclosed", STDERR_FILENO);
grid_free(grid, (*game)->map->height);
map_free((*game)->map);
// map_free((*game)->map);
return (FAILURE);
}
grid_free((*game)->map->grid, (*game)->map->height);

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* map_free.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/23 12:22:28 by whaffman #+# #+# */
/* Updated: 2025/05/28 14:30:16 by qmennen ### ########.fr */
/* :::::::: */
/* map_free.c :+: :+: */
/* +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/04/23 12:22:28 by whaffman #+# #+# */
/* Updated: 2025/05/29 12:05:59 by whaffman ######## odam.nl */
/* */
/* ************************************************************************** */
@ -16,6 +16,8 @@
void map_free(t_map *map)
{
int i;
if (!map)
return ;
grid_free(map->grid, map->height);
if (map->texture_floor)