X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fbase%2Flib_freeall.c;h=75c3ec3ea6215566312de88ceca6720ab00bc155;hp=dbdf443f00821155f1998aaf361c1a760fe796a2;hb=6b99a559185b3b8fad80b56bc2070b08101c33d1;hpb=37babca07fea18b480155ef60ef302ca09fca152 diff --git a/ncurses/base/lib_freeall.c b/ncurses/base/lib_freeall.c index dbdf443f..75c3ec3e 100644 --- a/ncurses/base/lib_freeall.c +++ b/ncurses/base/lib_freeall.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc. * + * Copyright (c) 1998-2017,2018 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 * @@ -31,7 +31,6 @@ ****************************************************************************/ #include -#include #include #if HAVE_NC_FREEALL @@ -40,7 +39,7 @@ extern int malloc_errfd; /* FIXME */ #endif -MODULE_ID("$Id: lib_freeall.c,v 1.57 2009/04/19 14:31:26 tom Exp $") +MODULE_ID("$Id: lib_freeall.c,v 1.69 2018/03/01 15:02:12 tom Exp $") /* * Free all ncurses data. This is used for testing only (there's no practical @@ -49,11 +48,11 @@ MODULE_ID("$Id: lib_freeall.c,v 1.57 2009/04/19 14:31:26 tom Exp $") NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_freeall) (NCURSES_SP_DCL0) { - WINDOWLIST *p, *q; static va_list empty_va; 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); @@ -61,29 +60,46 @@ 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 NCURSES_EXT_COLORS + _nc_new_pair_leaks(SP_PARM); +#endif } #endif if (SP_PARM != 0) { _nc_lock_global(curses); - while (_nc_windows != 0) { + while (WindowList(SP_PARM) != 0) { + WINDOWLIST *p, *q; bool deleted = FALSE; /* Delete only windows that're not a parent */ - for (each_window(p)) { + for (each_window(SP_PARM, p)) { + WINDOW *p_win = &(p->win); bool found = FALSE; - for (each_window(q)) { +#ifndef USE_SP_WINDOWLIST + if (p->screen != SP_PARM) + continue; +#endif + + for (each_window(SP_PARM, q)) { + WINDOW *q_win = &(q->win); + +#ifndef USE_SP_WINDOWLIST + if (q->screen != SP_PARM) + continue; +#endif + if ((p != q) - && (q->win._flags & _SUBWIN) - && (&(p->win) == q->win._parent)) { + && (q_win->_flags & _SUBWIN) + && (p_win == q_win->_parent)) { found = TRUE; break; } } if (!found) { - if (delwin(&(p->win)) != ERR) + if (delwin(p_win) != ERR) deleted = TRUE; break; } @@ -101,7 +117,7 @@ NCURSES_SP_NAME(_nc_freeall) (NCURSES_SP_DCL0) (void) _nc_printf_string(0, empty_va); #ifdef TRACE - (void) _nc_trace_buf(-1, 0); + (void) _nc_trace_buf(-1, (size_t) 0); #endif #if USE_WIDEC_SUPPORT FreeIfNeeded(_nc_wacs); @@ -130,8 +146,8 @@ _nc_freeall(void) NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_free_and_exit) (NCURSES_SP_DCLx int code) { - char *last_setbuf = (SP_PARM != 0) ? SP_PARM->_setbuf : 0; - + 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 */ @@ -140,8 +156,6 @@ NCURSES_SP_NAME(_nc_free_and_exit) (NCURSES_SP_DCLx int code) free(_nc_varargs("?", fake)); } #endif - fclose(stdout); - FreeIfNeeded(last_setbuf); exit(code); }