1 /* @(#)dbgmalloc.h 1.11 19/04/03 Copyright 2009-2019 J. Schilling */ 2 /* 3 * Definitions for libdmalloc 4 * 5 * Copyright (c) 2009-2019 J. Schilling 6 */ 7 /* 8 * The contents of this file are subject to the terms of the 9 * Common Development and Distribution License, Version 1.0 only 10 * (the "License"). You may not use this file except in compliance 11 * with the License. 12 * 13 * See the file CDDL.Schily.txt in this distribution for details. 14 * A copy of the CDDL is also available via the Internet at 15 * http://www.opensource.org/licenses/cddl1.txt 16 * 17 * When distributing Covered Code, include this CDDL HEADER in each 18 * file and include the License file CDDL.Schily.txt from this distribution. 19 */ 20 21 #ifndef _SCHILY_DBGMALLOC_H 22 #define _SCHILY_DBGMALLOC_H 23 24 #ifndef _SCHILY_MCONFIG_H 25 #include <schily/mconfig.h> 26 #endif 27 28 #ifdef DBG_MALLOC 29 #include <schily/types.h> 30 #include <schily/stdlib.h> 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 extern void *dbg_malloc __PR((size_t size, char *file, 37 int line)); 38 extern void *dbg_calloc __PR((size_t nelem, size_t elsize, 39 char *file, int line)); 40 extern void *dbg_realloc __PR((void *t, size_t size, char *file, 41 int line)); 42 extern void dbg_mark_alloc __PR((void *t, char *file, int line)); 43 44 #define malloc(s) dbg_malloc(s, __FILE__, __LINE__) 45 #define calloc(n, s) dbg_calloc(n, s, __FILE__, __LINE__) 46 #define realloc(t, s) dbg_realloc(t, s, __FILE__, __LINE__) 47 48 #define DBG_MALLOC_MARK(a) dbg_mark_alloc((a), __FILE__, __LINE__) 49 50 #ifdef __cplusplus 51 } 52 #endif 53 54 #else 55 #undef DBG_MALLOC_MARK 56 #define DBG_MALLOC_MARK(a) 57 #endif /* DBG_MALLOC */ 58 59 #ifdef USE_JS_BOOL /* #define USE_JS_BOOL if there is a */ 60 #define BOOL JS_BOOL /* different (incompatible) BOOL in */ 61 #endif /* the using code */ 62 #include <schily/standard.h> 63 64 #ifdef __cplusplus 65 extern "C" { 66 #endif 67 68 #ifndef FALSE 69 extern int acheckdamage __PR((void)); 70 extern void freechecking __PR((int val)); 71 extern void nomemraising __PR((int val)); 72 #else 73 extern BOOL acheckdamage __PR((void)); 74 extern void freechecking __PR((BOOL val)); 75 extern void nomemraising __PR((BOOL val)); 76 #endif 77 78 #if defined(_SCHILY_STDIO_H) && defined(EOF) 79 extern void aprintfree __PR((FILE *f)); 80 extern void aprintlist __PR((FILE *f, long l)); 81 extern void aprintchunk __PR((FILE *f, long l)); 82 #else 83 extern void aprintfree __PR((void *f)); 84 extern void aprintlist __PR((void *f, long l)); 85 extern void aprintchunk __PR((void *f, long l)); 86 #endif 87 88 extern size_t apsize __PR((char *t)); 89 extern void *get_heapbeg __PR((void)); 90 extern void *get_heapend __PR((void)); 91 92 #ifdef USE_JS_BOOL /* If in workaround mode, */ 93 #undef BOOL /* revert to default BOOL */ 94 #endif 95 96 #ifdef __cplusplus 97 } 98 #endif 99 100 #endif /* _SCHILY_DBGMALLOC_H */ 101