aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_exit.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-02 16:42:53 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-02 16:42:53 +0100
commit7a1f24cea4b042ced216a1aabb66d6d531c1bf65 (patch)
tree56f90e24eb67cead445710bec601a88805026943 /src/ft_exit.c
parentYES (diff)
download42-cub3d-7a1f24cea4b042ced216a1aabb66d6d531c1bf65.tar.gz
42-cub3d-7a1f24cea4b042ced216a1aabb66d6d531c1bf65.tar.bz2
42-cub3d-7a1f24cea4b042ced216a1aabb66d6d531c1bf65.tar.xz
42-cub3d-7a1f24cea4b042ced216a1aabb66d6d531c1bf65.tar.zst
42-cub3d-7a1f24cea4b042ced216a1aabb66d6d531c1bf65.zip
Music no leak
Diffstat (limited to '')
-rw-r--r--src/ft_exit.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/ft_exit.c b/src/ft_exit.c
index d4fb4f9..40860e7 100644
--- a/src/ft_exit.c
+++ b/src/ft_exit.c
@@ -29,6 +29,7 @@ static void
ft_memdel((void**)&clist->mlist->nl_tex_path);
ft_memdel((void**)&clist->mlist->nlevel_path);
ft_memdel((void**)&clist->mlist->music_path);
+ ft_memdel((void**)&clist->mlist->music_cmd);
ft_memdel((void**)&clist->mlist->mapl);
ft_free_words(clist->mlist->map);
ft_memdel((void**)&clist->mlist);
@@ -42,6 +43,9 @@ static void
int
ft_exit(uint8_t exit_code, t_cub *clist)
{
+ uint8_t ismus;
+ pthread_t ttid;
+
if (clist->walltexgood)
{
if (clist->tlist[0].img)
@@ -54,7 +58,7 @@ int
mlx_destroy_image(clist->wlist->wlx, clist->tlist[3].img);
if (clist->tlist[4].img)
mlx_destroy_image(clist->wlist->wlx, clist->tlist[4].img);
- if (clist->tlist[5].img && clist->mlist->isnlvl)
+ if (clist->mlist->isnlvl && clist->tlist[5].img)
mlx_destroy_image(clist->wlist->wlx, clist->tlist[5].img);
}
if (clist->wlist->inited)
@@ -62,10 +66,15 @@ int
mlx_destroy_window(clist->wlist->wlx, clist->wlist->winptr);
clist->wlist->winptr = NULL;
}
+ ismus = clist->mlist->ismusic;
+ ttid = clist->tid;
ft_free_lists(clist);
+ if (ismus)
+ {
+ pthread_cancel(ttid);
+ pthread_join(ttid, NULL);
+ }
ft_printf("Exiting program\n");
- pthread_cancel(clist->tid);
- pthread_exit(NULL);
exit(exit_code);
return (0);
}