1 /****************************************************************************
2 * Copyright 2019,2020 Thomas E. Dickey *
3 * Copyright 2006-2012,2017 Free Software Foundation, Inc. *
5 * Permission is hereby granted, free of charge, to any person obtaining a *
6 * copy of this software and associated documentation files (the *
7 * "Software"), to deal in the Software without restriction, including *
8 * without limitation the rights to use, copy, modify, merge, publish, *
9 * distribute, distribute with modifications, sublicense, and/or sell *
10 * copies of the Software, and to permit persons to whom the Software is *
11 * furnished to do so, subject to the following conditions: *
13 * The above copyright notice and this permission notice shall be included *
14 * in all copies or substantial portions of the Software. *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
19 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
22 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
24 * Except as contained in this notice, the name(s) of the above copyright *
25 * holders shall not be used in advertising or otherwise to promote the *
26 * sale, use or other dealings in this Software without prior written *
28 ****************************************************************************/
30 /****************************************************************************
31 * Author: Thomas E. Dickey *
32 * and: Juergen Pfeifer *
33 ****************************************************************************/
35 #include <curses.priv.h>
41 MODULE_ID("$Id: entries.c,v 1.30 2020/02/02 23:34:34 tom Exp $")
43 /****************************************************************************
45 * Entry queue handling
47 ****************************************************************************/
49 * The entry list is a doubly linked list with NULLs terminating the lists:
51 * --------- --------- ---------
53 * |-------| |-------| |-------|
54 * | ----+-->| ----+-->| NULL | next
55 * |-------| |-------| |-------|
56 * | NULL |<--+---- |<--+---- | last
57 * --------- --------- ---------
64 NCURSES_EXPORT_VAR(ENTRY *) _nc_head = 0;
65 NCURSES_EXPORT_VAR(ENTRY *) _nc_tail = 0;
68 _nc_delink_entry(ENTRY * headp, TERMTYPE2 *tterm)
69 /* delink the allocated storage for the given list entry */
73 for (last = 0, ep = headp; ep != 0; last = ep, ep = ep->next) {
74 if (&(ep->tterm) == tterm) {
76 last->next = ep->next;
79 ep->next->last = last;
94 _nc_free_entry(ENTRY * headp, TERMTYPE2 *tterm)
95 /* free the allocated storage consumed by the given list entry */
99 if ((ep = _nc_delink_entry(headp, tterm)) != 0) {
105 _nc_free_entries(ENTRY * headp)
106 /* free the allocated storage consumed by list entries */
108 (void) headp; /* unused - _nc_head is altered here! */
110 while (_nc_head != 0) {
111 _nc_free_termtype2(&(_nc_head->tterm));
116 _nc_leaks_tinfo(void)
122 T((T_CALLED("_nc_free_tinfo()")));
124 _nc_globals.leak_checking = TRUE;
128 if (TerminalOf(CURRENT_SCREEN) != 0) {
129 del_curterm(TerminalOf(CURRENT_SCREEN));
133 _nc_comp_captab_leaks();
134 _nc_comp_userdefs_leaks();
135 _nc_free_entries(_nc_head);
138 _nc_db_iterator_leaks();
140 #if BROKEN_LINKER || USE_REENTRANT
143 FreeIfNeeded(_nc_prescreen.real_acs_map);
145 _nc_comp_error_leaks();
147 if ((s = _nc_home_terminfo()) != 0)
153 _nc_trace_buf(-1, (size_t) 0);
156 #endif /* NO_LEAKS */
162 _nc_free_tinfo(int code)
170 exit_terminfo(int code)