/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_exit.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rbousset +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/14 17:28:46 by rbousset #+# #+# */ /* Updated: 2020/02/14 17:28:46 by rbousset ### ########lyon.fr */ /* */ /* ************************************************************************** */ #include #include #include #include #include #include #include #include static void ft_del_last_remains(t_cub *clist) { uint16_t i; i = 0; while (i < clist->big_t_val) { ft_memdel((void*)&clist->big_t[i]); i++; } ft_memdel((void*)&clist->big_t); if (!clist->wlist.inited) { ft_memdel((void*)&clist->wlist.winptr); ft_memdel((void*)&clist->wlist.wlx); } ft_memdel((void*)&clist); } static void ft_cancel_threads(t_cub *clist) { uint8_t i; if (clist->isoldmus && clist->wlist.inited) { system(FT_SND_TERM_CMD); } i = -1; while (++i < FT_TOTAL_SFX) { pthread_mutex_unlock(&clist->sfx[i].mutex); system(FT_SND_TERM_CMD); } } int ft_exit(uint8_t exit_code, t_cub *clist) { if (clist->walltexgood) ft_del_tex(clist); if (clist->wlist.inited) { if (FT_OS == 1) mlx_destroy_image(clist->wlist.wlx, clist->img.img); mlx_destroy_window(clist->wlist.wlx, clist->wlist.winptr); } ft_cancel_threads(clist); ft_del_map(&clist->mlist); ft_del_sprites_lists(clist); ft_del_sfx_cmd(clist); ft_del_last_remains(clist); ft_printf("Exiting program\n"); exit(exit_code); return (0); }