]> ncurses.scripts.mit.edu Git - ncurses.git/blob - ncurses/tinfo/free_ttype.c
973577636bcf45e37bcb9a0904704e55d32112c3
[ncurses.git] / ncurses / tinfo / free_ttype.c
1 /****************************************************************************
2  * Copyright 2020,2022 Thomas E. Dickey                                     *
3  * Copyright 1999-2011,2017 Free Software Foundation, Inc.                  *
4  *                                                                          *
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:                 *
12  *                                                                          *
13  * The above copyright notice and this permission notice shall be included  *
14  * in all copies or substantial portions of the Software.                   *
15  *                                                                          *
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.                               *
23  *                                                                          *
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       *
27  * authorization.                                                           *
28  ****************************************************************************/
29
30 /****************************************************************************
31  *  Author: Thomas E. Dickey                    1999-on                     *
32  ****************************************************************************/
33
34 /*
35  * free_ttype.c -- allocation functions for TERMTYPE
36  *
37  *      _nc_free_termtype()
38  *      use_extended_names()
39  *
40  */
41
42 #include <curses.priv.h>
43
44 #include <tic.h>
45
46 MODULE_ID("$Id: free_ttype.c,v 1.20 2022/05/15 12:42:13 tom Exp $")
47
48 static void
49 really_free_termtype(TERMTYPE2 *ptr, bool freeStrings)
50 {
51     T(("really_free_termtype(%s) %d", ptr->term_names, freeStrings));
52
53     if (freeStrings) {
54         FreeIfNeeded(ptr->str_table);
55     }
56     FreeIfNeeded(ptr->Booleans);
57     FreeIfNeeded(ptr->Numbers);
58     FreeIfNeeded(ptr->Strings);
59 #if NCURSES_XNAMES
60     if (freeStrings) {
61         FreeIfNeeded(ptr->ext_str_table);
62     }
63     FreeIfNeeded(ptr->ext_Names);
64 #endif
65     memset(ptr, 0, sizeof(TERMTYPE));
66     _nc_free_entry(_nc_head, ptr);
67 }
68
69 /*
70  * This entrypoint is used by tack 1.07
71  */
72 NCURSES_EXPORT(void)
73 _nc_free_termtype(TERMTYPE *ptr)
74 {
75     really_free_termtype((TERMTYPE2 *) ptr, !NCURSES_EXT_NUMBERS);
76 }
77
78 #if NCURSES_EXT_NUMBERS
79 NCURSES_EXPORT(void)
80 _nc_free_termtype2(TERMTYPE2 *ptr)
81 {
82     really_free_termtype(ptr, TRUE);
83 }
84 #endif
85
86 #if NCURSES_XNAMES
87 NCURSES_EXPORT_VAR(bool) _nc_user_definable = TRUE;
88
89 NCURSES_EXPORT(int)
90 use_extended_names(bool flag)
91 {
92     int oldflag = _nc_user_definable;
93
94     START_TRACE();
95     T((T_CALLED("use_extended_names(%d)"), flag));
96     _nc_user_definable = flag;
97     returnBool(oldflag);
98 }
99 #endif