1 /****************************************************************************
2 * Copyright 2019-2020,2021 Thomas E. Dickey *
3 * Copyright 1998-2013,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 1996-on *
32 ****************************************************************************/
33 /* $Id: nc_alloc.h,v 1.30 2021/11/20 23:33:38 tom Exp $ */
35 #ifndef NC_ALLOC_included
36 #define NC_ALLOC_included 1
39 #include <ncurses_cfg.h>
46 #if defined(HAVE_LIBDMALLOC) && HAVE_LIBDMALLOC
48 #undef strndup /* workaround for #define in GLIBC 2.7 */
49 #include <dmalloc.h> /* Gray Watson's library */
51 #undef HAVE_LIBDMALLOC
52 #define HAVE_LIBDMALLOC 0
55 #if defined(HAVE_LIBDBMALLOC) && HAVE_LIBDBMALLOC
56 #include <dbmalloc.h> /* Conor Cahill's library */
58 #undef HAVE_LIBDBMALLOC
59 #define HAVE_LIBDBMALLOC 0
62 #if defined(HAVE_LIBMPATROL) && HAVE_LIBMPATROL
63 #include <mpatrol.h> /* Memory-Patrol library */
65 #undef HAVE_LIBMPATROL
66 #define HAVE_LIBMPATROL 0
73 #if HAVE_LIBDBMALLOC || HAVE_LIBDMALLOC || NO_LEAKS
74 #define HAVE_NC_FREEALL 1
76 extern GCC_NORETURN NCURSES_EXPORT(void) _nc_free_tinfo(int) GCC_DEPRECATED("use exit_terminfo");
78 #ifdef NCURSES_INTERNALS
79 extern GCC_NORETURN NCURSES_EXPORT(void) _nc_free_tic(int);
80 extern void _nc_leaks_dump_entry(void);
81 extern NCURSES_EXPORT(void) _nc_leaks_tic(void);
84 extern GCC_NORETURN NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_free_and_exit)(SCREEN*, int);
86 extern GCC_NORETURN NCURSES_EXPORT(void) _nc_free_and_exit(int);
88 #else /* !NCURSES_INTERNALS */
89 extern GCC_NORETURN NCURSES_EXPORT(void) _nc_free_and_exit(int) GCC_DEPRECATED("use exit_curses");
92 #define ExitProgram(code) exit_curses(code)
95 extern GCC_NORETURN NCURSES_EXPORT(void) _nc_free_and_exit(int) GCC_DEPRECATED("use exit_curses");
96 #endif /* NO_LEAKS, etc */
98 #ifndef HAVE_NC_FREEALL
99 #define HAVE_NC_FREEALL 0
103 #define ExitProgram(code) exit(code)
107 extern NCURSES_EXPORT(void *) _nc_doalloc(void *, size_t);
110 #define strdup _nc_strdup
111 extern NCURSES_EXPORT(char *) _nc_strdup(const char *);
115 extern NCURSES_EXPORT(void) _nc_leaks_tinfo(void);
117 #define typeMalloc(type,elts) (type *)malloc((size_t)(elts)*sizeof(type))
118 #define typeCalloc(type,elts) (type *)calloc((size_t)(elts),sizeof(type))
119 #define typeRealloc(type,elts,ptr) (type *)_nc_doalloc(ptr, (size_t)(elts)*sizeof(type))
127 #endif /* NC_ALLOC_included */