Back to index

tetex-bin  3.0
nc_alloc.h
Go to the documentation of this file.
00001 /****************************************************************************
00002  * Copyright (c) 1998-2002,2004 Free Software Foundation, Inc.              *
00003  *                                                                          *
00004  * Permission is hereby granted, free of charge, to any person obtaining a  *
00005  * copy of this software and associated documentation files (the            *
00006  * "Software"), to deal in the Software without restriction, including      *
00007  * without limitation the rights to use, copy, modify, merge, publish,      *
00008  * distribute, distribute with modifications, sublicense, and/or sell       *
00009  * copies of the Software, and to permit persons to whom the Software is    *
00010  * furnished to do so, subject to the following conditions:                 *
00011  *                                                                          *
00012  * The above copyright notice and this permission notice shall be included  *
00013  * in all copies or substantial portions of the Software.                   *
00014  *                                                                          *
00015  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
00016  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
00017  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
00018  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
00019  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
00020  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
00021  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
00022  *                                                                          *
00023  * Except as contained in this notice, the name(s) of the above copyright   *
00024  * holders shall not be used in advertising or otherwise to promote the     *
00025  * sale, use or other dealings in this Software without prior written       *
00026  * authorization.                                                           *
00027  ****************************************************************************/
00028 
00029 /****************************************************************************
00030  *  Author: Thomas E. Dickey <dickey@clark.net> 1996,1997                   *
00031  ****************************************************************************/
00032 /* $Id: nc_alloc.h,v 1.12 2004/05/08 18:44:57 tom Exp $ */
00033 
00034 #ifndef NC_ALLOC_included
00035 #define NC_ALLOC_included 1
00036 
00037 #ifdef __cplusplus
00038 extern "C" {
00039 #endif
00040 
00041 #if HAVE_LIBDMALLOC
00042 #include <dmalloc.h>    /* Gray Watson's library */
00043 #else
00044 #undef  HAVE_LIBDMALLOC
00045 #define HAVE_LIBDMALLOC 0
00046 #endif
00047 
00048 #if HAVE_LIBDBMALLOC
00049 #include <dbmalloc.h>   /* Conor Cahill's library */
00050 #else
00051 #undef  HAVE_LIBDBMALLOC
00052 #define HAVE_LIBDBMALLOC 0
00053 #endif
00054 
00055 #ifndef NO_LEAKS
00056 #define NO_LEAKS 0
00057 #endif
00058 
00059 #if HAVE_LIBDBMALLOC || HAVE_LIBDMALLOC || NO_LEAKS
00060 #define HAVE_NC_FREEALL 1
00061 struct termtype;
00062 extern NCURSES_EXPORT(void) _nc_free_and_exit(int) GCC_NORETURN;
00063 extern NCURSES_EXPORT(void) _nc_free_tparm(void);
00064 extern NCURSES_EXPORT(void) _nc_leaks_dump_entry(void);
00065 #define ExitProgram(code) _nc_free_and_exit(code)
00066 #endif
00067 
00068 #ifndef HAVE_NC_FREEALL
00069 #define HAVE_NC_FREEALL 0
00070 #endif
00071 
00072 #ifndef ExitProgram
00073 #define ExitProgram(code) exit(code)
00074 #endif
00075 
00076 /* doalloc.c */
00077 extern NCURSES_EXPORT(void *) _nc_doalloc(void *, size_t);
00078 #if !HAVE_STRDUP
00079 #define strdup _nc_strdup
00080 extern NCURSES_EXPORT(char *) _nc_strdup(const char *);
00081 #endif
00082 
00083 #define typeMalloc(type,elts) (type *)malloc((elts)*sizeof(type))
00084 #define typeCalloc(type,elts) (type *)calloc((elts),sizeof(type))
00085 #define typeRealloc(type,elts,ptr) (type *)_nc_doalloc(ptr, (elts)*sizeof(type))
00086 
00087 #ifdef __cplusplus
00088 }
00089 #endif
00090 
00091 #endif /* NC_ALLOC_included */