diff options
Diffstat (limited to 'src/ft_exit.c')
-rw-r--r-- | src/ft_exit.c | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/src/ft_exit.c b/src/ft_exit.c index d140739..f753f84 100644 --- a/src/ft_exit.c +++ b/src/ft_exit.c @@ -50,6 +50,8 @@ static void static void ft_free_lists(t_cub *clist) { + uint8_t i; + ft_memdel((void*)&clist->mlist.filename); ft_memdel((void*)&clist->mlist.no_tex_path); ft_memdel((void*)&clist->mlist.so_tex_path); @@ -65,13 +67,11 @@ static void ft_memdel((void*)&clist->mlist.music_cmd); ft_memdel((void*)&clist->mlist.mapl); ft_free_words(clist->mlist.map); - ft_memdel((void*)&clist->sfx.death); - ft_memdel((void*)&clist->sfx.footstep_one); - ft_memdel((void*)&clist->sfx.footstep_two); - ft_memdel((void*)&clist->sfx.new_lvl); - ft_memdel((void*)&clist->sfx.pain_one); - ft_memdel((void*)&clist->sfx.pain_two); - ft_memdel((void*)&clist->sfx.trap); + i = -1; + while (++i < 10) + ft_memdel((void*)&clist->sfx[i].cmd); + ft_memdel((void*)&clist->sfx[1].cmd_alt); + ft_memdel((void*)&clist->sfx[3].cmd_alt); ft_free_sprites(clist->mlist.sprite_path); if (!clist->wlist.inited) ft_memdel((void*)&clist->wlist.winptr); @@ -108,26 +108,20 @@ static void static void ft_cancel_threads(t_cub *clist) { + uint8_t i; + if (clist->isoldmus && clist->wlist.inited) { pthread_cancel(clist->mtid); pthread_join(clist->mtid, NULL); } - pthread_mutex_unlock(&clist->sfx.death_mutex); - pthread_cancel(clist->sfx.death_tid); - pthread_join(clist->sfx.death_tid, NULL); - pthread_mutex_unlock(&clist->sfx.footstep_mutex); - pthread_cancel(clist->sfx.footstep_tid); - pthread_join(clist->sfx.footstep_tid, NULL); - pthread_mutex_unlock(&clist->sfx.new_lvl_mutex); - pthread_cancel(clist->sfx.new_lvl_tid); - pthread_join(clist->sfx.new_lvl_tid, NULL); - pthread_mutex_unlock(&clist->sfx.pain_mutex); - pthread_cancel(clist->sfx.pain_tid); - pthread_join(clist->sfx.pain_tid, NULL); - pthread_mutex_unlock(&clist->sfx.trap_mutex); - pthread_cancel(clist->sfx.trap_tid); - pthread_join(clist->sfx.trap_tid, NULL); + i = -1; + while (++i < 10) + { + pthread_mutex_unlock(&clist->sfx[i].mutex); + pthread_cancel(clist->sfx[i].tid); + pthread_join(clist->sfx[i].tid, NULL); + } } int |