1curs_memleaks(3X) curs_memleaks(3X)
2
3
4
6 exit_curses, exit_terminfo - curses memory-leak checking
7
9 #include <curses.h>
10 void exit_curses(int code);
11
12 #include <term.h>
13 void exit_terminfo(int code);
14
15 /* deprecated (intentionally not declared in curses.h or term.h) */
16 void _nc_freeall(void);
17 void _nc_free_and_exit(int code);
18 void _nc_free_tinfo(int code);
19
21 These functions are used to simplify analysis of memory leaks in the
22 ncurses library.
23
24 Any implementation of curses must not free the memory associated with a
25 screen, since (even after calling endwin(3X)), it must be available for
26 use in the next call to refresh(3X). There are also chunks of memory
27 held for performance reasons. That makes it hard to analyze curses ap‐
28 plications for memory leaks. When using the specially configured de‐
29 bugging version of the ncurses library, applications can call functions
30 which free those chunks of memory, simplifying the process of memory-
31 leak checking.
32
33 Some of the functions are named with a “_nc_” prefix because they are
34 not intended for use in the non-debugging library:
35
36 _nc_freeall
37 This frees (almost) all of the memory allocated by ncurses.
38
39 _nc_free_and_exit
40 This frees the memory allocated by ncurses (like _nc_freeall), and
41 exits the program. It is preferred over _nc_freeall since some of
42 that memory may be required to keep the application running. Sim‐
43 ply exiting (with the given exit-code) is safer.
44
45 _nc_free_tinfo
46 Use this function if only the low-level terminfo functions (and
47 corresponding library) are used. Like _nc_free_and_exit, it exits
48 the program after freeing memory.
49
50 The functions prefixed “_nc” are normally not available; they must be
51 configured into the library at build time using the --disable-leaks op‐
52 tion. That compiles-in code that frees memory that normally would not
53 be freed.
54
55 The exit_curses and exit_terminfo functions call _nc_free_and_exit and
56 _nc_free_tinfo if the library is configured to support memory-leak
57 checking. If the library is not configured to support memory-leak
58 checking, they simply call exit.
59
61 These functions do not return a value.
62
64 These functions are not part of X/Open Curses; nor do other implementa‐
65 tions of curses provide a similar feature.
66
67 In any implementation of X/Open Curses, an application can free part of
68 the memory allocated by curses:
69
70 • The portable part of exit_curses can be freed using delscreen,
71 passing the SCREEN* pointer returned by newterm.
72
73 In some implementations, there is a global variable sp which could
74 be used, e.g., if the screen were only initialized using initscr.
75
76 • The portable part of exit_terminfo can be freed using del_curterm.
77
78 In this case, there is a global variable cur_term which can be used
79 as parameter.
80
82 curs_initscr(3X), curs_terminfo(3X). curses(3X).
83
84
85
86 curs_memleaks(3X)