X-Git-Url: https://ncurses.scripts.mit.edu/?a=blobdiff_plain;ds=sidebyside;f=ncurses%2Fbase%2Flib_freeall.c;h=75bbe77e34093be4c4efa70b4a40f18da2abaac1;hb=214f159cd8c0ea4fba47beb249379d0da2dfb8ca;hp=65c77aacfc3b0ecf7b05981932143218ed50cd5c;hpb=2e68dc325852af56f2ec6c315b323a4f9c3d62c9;p=ncurses.git diff --git a/ncurses/base/lib_freeall.c b/ncurses/base/lib_freeall.c index 65c77aac..75bbe77e 100644 --- a/ncurses/base/lib_freeall.c +++ b/ncurses/base/lib_freeall.c @@ -1,5 +1,6 @@ /**************************************************************************** - * Copyright (c) 1998-2016,2017 Free Software Foundation, Inc. * + * Copyright 2018-2020,2021 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -39,7 +40,7 @@ extern int malloc_errfd; /* FIXME */ #endif -MODULE_ID("$Id: lib_freeall.c,v 1.66 2017/03/25 22:59:38 tom Exp $") +MODULE_ID("$Id: lib_freeall.c,v 1.76 2021/11/06 21:52:49 tom Exp $") /* * Free all ncurses data. This is used for testing only (there's no practical @@ -52,6 +53,7 @@ NCURSES_SP_NAME(_nc_freeall) (NCURSES_SP_DCL0) T((T_CALLED("_nc_freeall()"))); #if NO_LEAKS + _nc_globals.leak_checking = TRUE; if (SP_PARM != 0) { if (SP_PARM->_oldnum_list != 0) { FreeAndNull(SP_PARM->_oldnum_list); @@ -59,7 +61,7 @@ NCURSES_SP_NAME(_nc_freeall) (NCURSES_SP_DCL0) if (SP_PARM->_panelHook.destroy != 0) { SP_PARM->_panelHook.destroy(SP_PARM->_panelHook.stdscr_pseudo_panel); } -#if USE_NEW_PAIR +#if NCURSES_EXT_COLORS _nc_new_pair_leaks(SP_PARM); #endif } @@ -76,6 +78,9 @@ NCURSES_SP_NAME(_nc_freeall) (NCURSES_SP_DCL0) WINDOW *p_win = &(p->win); bool found = FALSE; + if (IS_PAD(p_win)) + continue; + #ifndef USE_SP_WINDOWLIST if (p->screen != SP_PARM) continue; @@ -90,7 +95,7 @@ NCURSES_SP_NAME(_nc_freeall) (NCURSES_SP_DCL0) #endif if ((p != q) - && (q_win->_flags & _SUBWIN) + && IS_SUBWIN(q_win) && (p_win == q_win->_parent)) { found = TRUE; break; @@ -145,10 +150,11 @@ _nc_freeall(void) NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_free_and_exit) (NCURSES_SP_DCLx int code) { + T((T_CALLED("_nc_free_and_exit(%d)"), code)); NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG); NCURSES_SP_NAME(_nc_freeall) (NCURSES_SP_ARG); #ifdef TRACE - trace(0); /* close trace file, freeing its setbuf */ + curses_trace(0); /* close trace file, freeing its setbuf */ { static va_list fake; free(_nc_varargs("?", fake)); @@ -157,7 +163,7 @@ NCURSES_SP_NAME(_nc_free_and_exit) (NCURSES_SP_DCLx int code) exit(code); } -#else +#else /* !HAVE_NC_FREEALL */ NCURSES_EXPORT(void) _nc_freeall(void) { @@ -168,12 +174,10 @@ NCURSES_SP_NAME(_nc_free_and_exit) (NCURSES_SP_DCLx int code) { if (SP_PARM) { delscreen(SP_PARM); - if (SP_PARM->_term) - NCURSES_SP_NAME(del_curterm) (NCURSES_SP_ARGx SP_PARM->_term); } exit(code); } -#endif +#endif /* HAVE_NC_FREEALL */ #if NCURSES_SP_FUNCS NCURSES_EXPORT(void) @@ -182,3 +186,16 @@ _nc_free_and_exit(int code) NCURSES_SP_NAME(_nc_free_and_exit) (CURRENT_SCREEN, code); } #endif + +NCURSES_EXPORT(void) +exit_curses(int code) +{ +#if NO_LEAKS +#if NCURSES_SP_FUNCS + NCURSES_SP_NAME(_nc_free_and_exit) (CURRENT_SCREEN, code); +#else + _nc_free_and_exit(code); /* deprecated... */ +#endif +#endif + exit(code); +}