aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_exit.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ft_exit.c')
-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);
}