150276Speter/**************************************************************************** 2184989Srafan * Copyright (c) 1998-2007,2008 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/**************************************************************************** 30184989Srafan * Author: Thomas E. Dickey 1996-on * 3150276Speter ****************************************************************************/ 32184989Srafan/* $Id: nc_alloc.h,v 1.16 2008/09/27 22:30:33 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 42184989Srafan#include <string.h> 43184989Srafan#undef strndup /* workaround for #define in GLIBC 2.7 */ 4450276Speter#include <dmalloc.h> /* Gray Watson's library */ 4550276Speter#else 4650276Speter#undef HAVE_LIBDMALLOC 4750276Speter#define HAVE_LIBDMALLOC 0 4850276Speter#endif 4950276Speter 5050276Speter#if HAVE_LIBDBMALLOC 5150276Speter#include <dbmalloc.h> /* Conor Cahill's library */ 5250276Speter#else 5350276Speter#undef HAVE_LIBDBMALLOC 5450276Speter#define HAVE_LIBDBMALLOC 0 5550276Speter#endif 5650276Speter 57166124Srafan#if HAVE_LIBMPATROL 58166124Srafan#include <mpatrol.h> /* Memory-Patrol library */ 59166124Srafan#else 60166124Srafan#undef HAVE_LIBMPATROL 61166124Srafan#define HAVE_LIBMPATROL 0 62166124Srafan#endif 63166124Srafan 6450276Speter#ifndef NO_LEAKS 6550276Speter#define NO_LEAKS 0 6650276Speter#endif 6750276Speter 6850276Speter#if HAVE_LIBDBMALLOC || HAVE_LIBDMALLOC || NO_LEAKS 6950276Speter#define HAVE_NC_FREEALL 1 7050276Speterstruct termtype; 71166124Srafanextern NCURSES_EXPORT(void) _nc_free_and_exit(int) GCC_NORETURN; 72174993Srafanextern NCURSES_EXPORT(void) _nc_free_tinfo(int) GCC_NORETURN; 73174993Srafanextern NCURSES_EXPORT(void) _nc_free_tic(int) GCC_NORETURN; 74166124Srafanextern NCURSES_EXPORT(void) _nc_free_tparm(void); 75166124Srafanextern NCURSES_EXPORT(void) _nc_leaks_dump_entry(void); 76174993Srafanextern NCURSES_EXPORT(void) _nc_leaks_tic(void); 7750276Speter#define ExitProgram(code) _nc_free_and_exit(code) 7850276Speter#endif 7950276Speter 8050276Speter#ifndef HAVE_NC_FREEALL 8150276Speter#define HAVE_NC_FREEALL 0 8250276Speter#endif 8350276Speter 8450276Speter#ifndef ExitProgram 8597049Speter#define ExitProgram(code) exit(code) 8650276Speter#endif 8750276Speter 8862449Speter/* doalloc.c */ 8997049Speterextern NCURSES_EXPORT(void *) _nc_doalloc(void *, size_t); 9062449Speter#if !HAVE_STRDUP 9162449Speter#define strdup _nc_strdup 9297049Speterextern NCURSES_EXPORT(char *) _nc_strdup(const char *); 9362449Speter#endif 9462449Speter 95174993Srafan/* entries.c */ 96174993Srafanextern NCURSES_EXPORT(void) _nc_leaks_tinfo(void); 97174993Srafan 9862449Speter#define typeMalloc(type,elts) (type *)malloc((elts)*sizeof(type)) 9962449Speter#define typeCalloc(type,elts) (type *)calloc((elts),sizeof(type)) 10062449Speter#define typeRealloc(type,elts,ptr) (type *)_nc_doalloc(ptr, (elts)*sizeof(type)) 10162449Speter 102166124Srafan#ifdef __cplusplus 103166124Srafan} 104166124Srafan#endif 105166124Srafan 10650276Speter#endif /* NC_ALLOC_included */ 107