1999-08-24 01:06:48 +00:00
|
|
|
/****************************************************************************
|
2014-03-01 00:40:26 +00:00
|
|
|
* Copyright (c) 1998-2012,2013 Free Software Foundation, Inc. *
|
1999-08-24 01:06:48 +00:00
|
|
|
* *
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a *
|
|
|
|
* copy of this software and associated documentation files (the *
|
|
|
|
* "Software"), to deal in the Software without restriction, including *
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish, *
|
|
|
|
* distribute, distribute with modifications, sublicense, and/or sell *
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is *
|
|
|
|
* furnished to do so, subject to the following conditions: *
|
|
|
|
* *
|
|
|
|
* The above copyright notice and this permission notice shall be included *
|
|
|
|
* in all copies or substantial portions of the Software. *
|
|
|
|
* *
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
|
|
|
|
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
|
|
|
|
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
|
|
|
|
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
|
|
|
|
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
|
|
|
* *
|
|
|
|
* Except as contained in this notice, the name(s) of the above copyright *
|
|
|
|
* holders shall not be used in advertising or otherwise to promote the *
|
|
|
|
* sale, use or other dealings in this Software without prior written *
|
|
|
|
* authorization. *
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2008-11-09 14:08:54 +00:00
|
|
|
* Author: Thomas E. Dickey 1996-on *
|
1999-08-24 01:06:48 +00:00
|
|
|
****************************************************************************/
|
2014-03-01 00:40:26 +00:00
|
|
|
/* $Id: nc_alloc.h,v 1.22 2013/01/26 21:56:51 tom Exp $ */
|
1999-08-24 01:06:48 +00:00
|
|
|
|
|
|
|
#ifndef NC_ALLOC_included
|
|
|
|
#define NC_ALLOC_included 1
|
2014-03-01 00:40:26 +00:00
|
|
|
/* *INDENT-OFF* */
|
1999-08-24 01:06:48 +00:00
|
|
|
|
2007-01-20 07:32:02 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2014-02-28 19:18:07 +00:00
|
|
|
#if defined(HAVE_LIBDMALLOC) && HAVE_LIBDMALLOC
|
2008-11-09 14:08:54 +00:00
|
|
|
#include <string.h>
|
|
|
|
#undef strndup /* workaround for #define in GLIBC 2.7 */
|
1999-08-24 01:06:48 +00:00
|
|
|
#include <dmalloc.h> /* Gray Watson's library */
|
|
|
|
#else
|
|
|
|
#undef HAVE_LIBDMALLOC
|
|
|
|
#define HAVE_LIBDMALLOC 0
|
|
|
|
#endif
|
|
|
|
|
2014-02-28 19:18:07 +00:00
|
|
|
#if defined(HAVE_LIBDBMALLOC) && HAVE_LIBDBMALLOC
|
1999-08-24 01:06:48 +00:00
|
|
|
#include <dbmalloc.h> /* Conor Cahill's library */
|
|
|
|
#else
|
|
|
|
#undef HAVE_LIBDBMALLOC
|
|
|
|
#define HAVE_LIBDBMALLOC 0
|
|
|
|
#endif
|
|
|
|
|
2014-02-28 19:18:07 +00:00
|
|
|
#if defined(HAVE_LIBMPATROL) && HAVE_LIBMPATROL
|
2007-01-20 07:32:02 +00:00
|
|
|
#include <mpatrol.h> /* Memory-Patrol library */
|
|
|
|
#else
|
|
|
|
#undef HAVE_LIBMPATROL
|
|
|
|
#define HAVE_LIBMPATROL 0
|
|
|
|
#endif
|
|
|
|
|
1999-08-24 01:06:48 +00:00
|
|
|
#ifndef NO_LEAKS
|
|
|
|
#define NO_LEAKS 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAVE_LIBDBMALLOC || HAVE_LIBDMALLOC || NO_LEAKS
|
|
|
|
#define HAVE_NC_FREEALL 1
|
|
|
|
struct termtype;
|
2007-01-20 07:32:02 +00:00
|
|
|
extern NCURSES_EXPORT(void) _nc_free_and_exit(int) GCC_NORETURN;
|
2007-12-30 11:08:14 +00:00
|
|
|
extern NCURSES_EXPORT(void) _nc_free_tinfo(int) GCC_NORETURN;
|
|
|
|
extern NCURSES_EXPORT(void) _nc_free_tic(int) GCC_NORETURN;
|
2007-01-20 07:32:02 +00:00
|
|
|
extern NCURSES_EXPORT(void) _nc_free_tparm(void);
|
|
|
|
extern NCURSES_EXPORT(void) _nc_leaks_dump_entry(void);
|
2007-12-30 11:08:14 +00:00
|
|
|
extern NCURSES_EXPORT(void) _nc_leaks_tic(void);
|
2014-02-28 19:18:07 +00:00
|
|
|
|
|
|
|
#if NCURSES_SP_FUNCS
|
|
|
|
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_free_and_exit)(SCREEN*, int) GCC_NORETURN;
|
2014-02-28 19:12:44 +00:00
|
|
|
#endif
|
2011-04-30 10:55:14 +00:00
|
|
|
|
2014-02-28 19:18:07 +00:00
|
|
|
#define ExitProgram(code) _nc_free_and_exit(code)
|
|
|
|
|
|
|
|
#endif /* NO_LEAKS, etc */
|
|
|
|
|
1999-08-24 01:06:48 +00:00
|
|
|
#ifndef HAVE_NC_FREEALL
|
|
|
|
#define HAVE_NC_FREEALL 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef ExitProgram
|
2002-05-21 05:30:25 +00:00
|
|
|
#define ExitProgram(code) exit(code)
|
1999-08-24 01:06:48 +00:00
|
|
|
#endif
|
|
|
|
|
2000-07-03 09:24:12 +00:00
|
|
|
/* doalloc.c */
|
2002-05-21 05:30:25 +00:00
|
|
|
extern NCURSES_EXPORT(void *) _nc_doalloc(void *, size_t);
|
2000-07-03 09:24:12 +00:00
|
|
|
#if !HAVE_STRDUP
|
2014-03-01 00:40:26 +00:00
|
|
|
#undef strdup
|
2000-07-03 09:24:12 +00:00
|
|
|
#define strdup _nc_strdup
|
2002-05-21 05:30:25 +00:00
|
|
|
extern NCURSES_EXPORT(char *) _nc_strdup(const char *);
|
2000-07-03 09:24:12 +00:00
|
|
|
#endif
|
|
|
|
|
2007-12-30 11:08:14 +00:00
|
|
|
/* entries.c */
|
|
|
|
extern NCURSES_EXPORT(void) _nc_leaks_tinfo(void);
|
|
|
|
|
2014-03-01 00:40:26 +00:00
|
|
|
#define typeMalloc(type,elts) (type *)malloc((size_t)(elts)*sizeof(type))
|
|
|
|
#define typeCalloc(type,elts) (type *)calloc((size_t)(elts),sizeof(type))
|
|
|
|
#define typeRealloc(type,elts,ptr) (type *)_nc_doalloc(ptr, (size_t)(elts)*sizeof(type))
|
2000-07-03 09:24:12 +00:00
|
|
|
|
2007-01-20 07:32:02 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-03-01 00:40:26 +00:00
|
|
|
/* *INDENT-ON* */
|
|
|
|
|
1999-08-24 01:06:48 +00:00
|
|
|
#endif /* NC_ALLOC_included */
|