2 * fda.c - Free Debug Allocator
3 * Copyright (C) 1997 Thomas Helvey <tomh@inxpress.net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef INCLUDED_fda_h
22 #define INCLUDED_fda_h
25 #ifndef INCLUDED_sys_types_h
26 #include <sys/types.h> /* size_t */
27 #define INCLUDED_sys_types_h
35 extern size_t fda_get_byte_count(void);
36 extern size_t fda_get_block_count(void);
37 extern size_t fda_sizeof(const void* p);
38 extern void fda_clear_refs(void);
39 extern void fda_set_ref(const void* p);
40 extern void fda_assert_refs(void);
41 extern int fda_enum_locations(void (*enumfn)(const char*, int, int));
42 extern int fda_enum_leaks(void (*enumfn)(const char*, int, size_t, void*));
43 extern void fda_dump_hash(void (*enumfn)(int, int));
44 extern void fda_set_byte_limit(size_t nbytes);
45 extern int valid_ptr(const void* p, size_t size);
47 extern void* fda_malloc(size_t size, const char* file, int line);
48 extern void* fda_realloc(void* p, size_t size, const char* file, int line);
49 extern void* fda_calloc(size_t nelems, size_t size, const char* file, int line);
50 extern char* fda_strdup(const char* src, const char* file, int line);
51 extern void fda_free(void* p);
53 #if defined(FDA_REDEFINE_MALLOC)
54 #define malloc(s) fda_malloc((s), __FILE__, __LINE__)
55 #define realloc(p, s) fda_realloc((p), (s), __FILE__, __LINE__)
56 #define calloc(n, s) fda_calloc((n), (s), __FILE__, __LINE__)
57 #define strdup(s) fda_strdup((s), __FILE__, __LINE__)
58 #define free(p) fda_free((p))
61 extern void fda_set_lowmem_handler(void (*fn)(void));
62 extern void fda_set_nomem_handler(void (*fn)(void));
68 #endif /* !defined(NDEBUG) */
69 #endif /* INCLUDED_fda_h */