nc_alloc.h revision 174993
150276Speter/**************************************************************************** 2174993Srafan * Copyright (c) 1998-2005,2007 Free Software Foundation, Inc. * 350276Speter * * 450276Speter * Permission is hereby granted, free of charge, to any person obtaining a * 550276Speter * copy of this software and associated documentation files (the * 650276Speter * "Software"), to deal in the Software without restriction, including * 750276Speter * without limitation the rights to use, copy, modify, merge, publish, * 850276Speter * distribute, distribute with modifications, sublicense, and/or sell * 950276Speter * copies of the Software, and to permit persons to whom the Software is * 1050276Speter * furnished to do so, subject to the following conditions: * 1150276Speter * * 1250276Speter * The above copyright notice and this permission notice shall be included * 1350276Speter * in all copies or substantial portions of the Software. * 1450276Speter * * 1550276Speter * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 1650276Speter * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 1750276Speter * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 1850276Speter * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 1950276Speter * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 2050276Speter * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 2150276Speter * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 2250276Speter * * 2350276Speter * Except as contained in this notice, the name(s) of the above copyright * 2450276Speter * holders shall not be used in advertising or otherwise to promote the * 2550276Speter * sale, use or other dealings in this Software without prior written * 2650276Speter * authorization. * 2750276Speter ****************************************************************************/ 2850276Speter 2950276Speter/**************************************************************************** 3050276Speter * Author: Thomas E. Dickey <dickey@clark.net> 1996,1997 * 3150276Speter ****************************************************************************/ 32174993Srafan/* $Id: nc_alloc.h,v 1.15 2007/02/03 18:40:23 tom Exp $ */ 3350276Speter 3450276Speter#ifndef NC_ALLOC_included 3550276Speter#define NC_ALLOC_included 1 3650276Speter 37166124Srafan#ifdef __cplusplus 38166124Srafanextern "C" { 39166124Srafan#endif 40166124Srafan 4150276Speter#if HAVE_LIBDMALLOC 4250276Speter#include <dmalloc.h> /* Gray Watson's library */ 4350276Speter#else 4450276Speter#undef HAVE_LIBDMALLOC 4550276Speter#define HAVE_LIBDMALLOC 0 4650276Speter#endif 4750276Speter 4850276Speter#if HAVE_LIBDBMALLOC 4950276Speter#include <dbmalloc.h> /* Conor Cahill's library */ 5050276Speter#else 5150276Speter#undef HAVE_LIBDBMALLOC 5250276Speter#define HAVE_LIBDBMALLOC 0 5350276Speter#endif 5450276Speter 55166124Srafan#if HAVE_LIBMPATROL 56166124Srafan#include <mpatrol.h> /* Memory-Patrol library */ 57166124Srafan#else 58166124Srafan#undef HAVE_LIBMPATROL 59166124Srafan#define HAVE_LIBMPATROL 0 60166124Srafan#endif 61166124Srafan 6250276Speter#ifndef NO_LEAKS 6350276Speter#define NO_LEAKS 0 6450276Speter#endif 6550276Speter 6650276Speter#if HAVE_LIBDBMALLOC || HAVE_LIBDMALLOC || NO_LEAKS 6750276Speter#define HAVE_NC_FREEALL 1 6850276Speterstruct termtype; 69166124Srafanextern NCURSES_EXPORT(void) _nc_free_and_exit(int) GCC_NORETURN; 70174993Srafanextern NCURSES_EXPORT(void) _nc_free_tinfo(int) GCC_NORETURN; 71174993Srafanextern NCURSES_EXPORT(void) _nc_free_tic(int) GCC_NORETURN; 72166124Srafanextern NCURSES_EXPORT(void) _nc_free_tparm(void); 73166124Srafanextern NCURSES_EXPORT(void) _nc_leaks_dump_entry(void); 74174993Srafanextern NCURSES_EXPORT(void) _nc_leaks_tic(void); 7550276Speter#define ExitProgram(code) _nc_free_and_exit(code) 7650276Speter#endif 7750276Speter 7850276Speter#ifndef HAVE_NC_FREEALL 7950276Speter#define HAVE_NC_FREEALL 0 8050276Speter#endif 8150276Speter 8250276Speter#ifndef ExitProgram 8397049Speter#define ExitProgram(code) exit(code) 8450276Speter#endif 8550276Speter 8662449Speter/* doalloc.c */ 8797049Speterextern NCURSES_EXPORT(void *) _nc_doalloc(void *, size_t); 8862449Speter#if !HAVE_STRDUP 8962449Speter#define strdup _nc_strdup 9097049Speterextern NCURSES_EXPORT(char *) _nc_strdup(const char *); 9162449Speter#endif 9262449Speter 93174993Srafan/* entries.c */ 94174993Srafanextern NCURSES_EXPORT(void) _nc_leaks_tinfo(void); 95174993Srafan 9662449Speter#define typeMalloc(type,elts) (type *)malloc((elts)*sizeof(type)) 9762449Speter#define typeCalloc(type,elts) (type *)calloc((elts),sizeof(type)) 9862449Speter#define typeRealloc(type,elts,ptr) (type *)_nc_doalloc(ptr, (elts)*sizeof(type)) 9962449Speter 100166124Srafan#ifdef __cplusplus 101166124Srafan} 102166124Srafan#endif 103166124Srafan 10450276Speter#endif /* NC_ALLOC_included */ 105