Skip to content

Commit

Permalink
Fixed stupid segfault in cleanup due to mlx pointer and img pointer b…
Browse files Browse the repository at this point in the history
…eing swapped in mlx_destroy_img()
  • Loading branch information
Jean Teissier authored and Jean Teissier committed Aug 30, 2024
1 parent e71e46d commit abd0121
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion maps/subject_test.cub
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NO ./assets/okan.xpm
NO ./assets/dummy.xpm
SO ./assets/yohurteb.xpm
WE ./assets/okan.xpm
EA ./assets/okan.xpm
Expand Down
18 changes: 9 additions & 9 deletions srcs/cleanup.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,22 @@
/* By: jteissie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/27 17:04:32 by jteissie #+# #+# */
/* Updated: 2024/08/29 17:45:39 by jteissie ### ########.fr */
/* Updated: 2024/08/30 14:31:07 by jteissie ### ########.fr */
/* */
/* ************************************************************************** */

#include "cub3d.h"

static void cleanup_textures(t_textdata *textures, void *mlx)
{
if (textures->text_img[N])
mlx_destroy_image(mlx, textures->text_img[N]);
if (textures->text_img[S])
mlx_destroy_image(mlx, textures->text_img[S]);
if (textures->text_img[E])
mlx_destroy_image(mlx, textures->text_img[E]);
if (textures->text_img[W])
mlx_destroy_image(mlx, textures->text_img[W]);
if (textures->text_paths[N])
free(textures->text_paths[N]);
if (textures->text_paths[S])
Expand All @@ -22,14 +30,6 @@ static void cleanup_textures(t_textdata *textures, void *mlx)
free(textures->text_paths[E]);
if (textures->text_paths[W])
free(textures->text_paths[W]);
if (textures->text_img[N])
mlx_destroy_image(textures->text_img[N], mlx);
if (textures->text_img[S])
mlx_destroy_image(textures->text_img[S], mlx);
if (textures->text_img[E])
mlx_destroy_image(textures->text_img[E], mlx);
if (textures->text_img[W])
mlx_destroy_image(textures->text_img[W], mlx);
free(textures);
}

Expand Down
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: jteissie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/27 17:03:43 by jteissie #+# #+# */
/* Updated: 2024/08/29 17:53:43 by jteissie ### ########.fr */
/* Updated: 2024/08/30 14:30:35 by jteissie ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down

0 comments on commit abd0121

Please sign in to comment.