1 /******************************************************************************
2 * Copyright 1996 by Thomas E. Dickey <dickey@clark.net> *
3 * All Rights Reserved. *
5 * Permission to use, copy, modify, and distribute this software and its *
6 * documentation for any purpose and without fee is hereby granted, provided *
7 * that the above copyright notice appear in all copies and that both that *
8 * copyright notice and this permission notice appear in supporting *
9 * documentation, and that the name of the above listed copyright holder(s) *
10 * not be used in advertising or publicity pertaining to distribution of the *
11 * software without specific, written prior permission. THE ABOVE LISTED *
12 * COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *
13 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO *
14 * EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY *
15 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER *
16 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF *
17 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN *
18 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *
19 ******************************************************************************/
21 #define HAVE_NC_FREEALL 1
23 #include <curses.priv.h>
27 extern int malloc_errfd; /* FIXME */
30 MODULE_ID("$Id: lib_freeall.c,v 1.8 1997/02/15 18:53:43 tom Exp $")
32 static void free_slk(SLK *p)
36 FreeIfNeeded(p->buffer);
41 void _nc_free_termtype(struct termtype *p, int base)
44 FreeIfNeeded(p->term_names);
45 FreeIfNeeded(p->str_table);
51 static void free_tries(struct tries *p)
65 * Free all ncurses data. This is used for testing only (there's no practical
66 * use for it as an extension).
68 void _nc_freeall(void)
75 while (_nc_windows != 0) {
76 /* Delete only windows that're not a parent */
77 for (p = _nc_windows; p != 0; p = p->next) {
80 for (q = _nc_windows; q != 0; q = q->next) {
82 && (q->win->_flags & _SUBWIN)
83 && (p->win == q->win->_parent)) {
97 free_tries (SP->_keytry);
99 FreeIfNeeded(SP->_color_pairs);
100 FreeIfNeeded(SP->_color_table);
101 _nc_set_buffer(SP->_ofp, FALSE);
108 _nc_free_termtype(&(cur_term->type), TRUE);
112 malloc_dump(malloc_errfd);
113 #elif HAVE_LIBDMALLOC
119 void _nc_free_and_exit(int code)