1 /****************************************************************************
2 * Copyright (c) 2006-2011,2012 Free Software Foundation, Inc. *
4 * Permission is hereby granted, free of charge, to any person obtaining a *
5 * copy of this software and associated documentation files (the *
6 * "Software"), to deal in the Software without restriction, including *
7 * without limitation the rights to use, copy, modify, merge, publish, *
8 * distribute, distribute with modifications, sublicense, and/or sell *
9 * copies of the Software, and to permit persons to whom the Software is *
10 * furnished to do so, subject to the following conditions: *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 * Except as contained in this notice, the name(s) of the above copyright *
24 * holders shall not be used in advertising or otherwise to promote the *
25 * sale, use or other dealings in this Software without prior written *
27 ****************************************************************************/
29 /****************************************************************************
30 * Author: Thomas E. Dickey *
31 * and: Juergen Pfeifer *
32 ****************************************************************************/
34 #include <curses.priv.h>
40 MODULE_ID("$Id: entries.c,v 1.21 2012/05/05 20:33:44 tom Exp $")
42 /****************************************************************************
44 * Entry queue handling
46 ****************************************************************************/
48 * The entry list is a doubly linked list with NULLs terminating the lists:
50 * --------- --------- ---------
52 * |-------| |-------| |-------|
53 * | ----+-->| ----+-->| NULL | next
54 * |-------| |-------| |-------|
55 * | NULL |<--+---- |<--+---- | last
56 * --------- --------- ---------
63 NCURSES_EXPORT_VAR(ENTRY *) _nc_head = 0;
64 NCURSES_EXPORT_VAR(ENTRY *) _nc_tail = 0;
67 _nc_free_entry(ENTRY * headp, TERMTYPE *tterm)
68 /* free the allocated storage consumed by the given list entry */
72 if ((ep = _nc_delink_entry(headp, tterm)) != 0) {
78 _nc_free_entries(ENTRY * headp)
79 /* free the allocated storage consumed by list entries */
81 (void) headp; /* unused - _nc_head is altered here! */
83 while (_nc_head != 0) {
84 _nc_free_termtype(&(_nc_head->tterm));
88 NCURSES_EXPORT(ENTRY *)
89 _nc_delink_entry(ENTRY * headp, TERMTYPE *tterm)
90 /* delink the allocated storage for the given list entry */
94 for (last = 0, ep = headp; ep != 0; last = ep, ep = ep->next) {
95 if (&(ep->tterm) == tterm) {
97 last->next = ep->next;
100 ep->next->last = last;
102 if (ep == _nc_head) {
105 if (ep == _nc_tail) {
115 _nc_leaks_tinfo(void)
121 T((T_CALLED("_nc_free_tinfo()")));
126 if (TerminalOf(CURRENT_SCREEN) != 0) {
127 del_curterm(TerminalOf(CURRENT_SCREEN));
130 _nc_comp_captab_leaks();
131 _nc_free_entries(_nc_head);
134 _nc_db_iterator_leaks();
136 #if BROKEN_LINKER || USE_REENTRANT
139 FreeIfNeeded(_nc_prescreen.real_acs_map);
141 _nc_comp_error_leaks();
143 if ((s = _nc_home_terminfo()) != 0)
148 _nc_trace_buf(-1, (size_t) 0);
151 #endif /* NO_LEAKS */
157 _nc_free_tinfo(int code)