1 /*
2    Memory leak wrappers
3    Copyright (C) 2003, Joe Orton <joe@manyfish.co.uk>
4 
5    This library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Library General Public
7    License as published by the Free Software Foundation; either
8    version 2 of the License, or (at your option) any later version.
9 
10    This library 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 GNU
13    Library General Public License for more details.
14 
15    You should have received a copy of the GNU Library General Public
16    License along with this library; if not, write to the Free
17    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18    MA 02111-1307, USA
19 
20 */
21 
22 /* WARNING: THIS IS AN INTERNAL NEON INTERFACE AND MUST NOT BE USED
23  * from NEON APPLICATIONS. */
24 
25 /* This file contains an alternate interface to the memory allocation
26  * wrappers in ne_alloc.c, which perform simple leak detection.  It
27  * MUST NOT BE INSTALLED, or used from neon applications. */
28 
29 #ifndef MEMLEAK_H
30 #define MEMLEAK_H
31 
32 #include <stdio.h>
33 
34 #define ne_malloc(s) ne_malloc_ml(s, __FILE__, __LINE__)
35 #define ne_calloc(s) ne_calloc_ml(s, __FILE__, __LINE__)
36 #define ne_realloc(p, s) ne_realloc_ml(p, s, __FILE__, __LINE__)
37 #define ne_strdup(s) ne_strdup_ml(s, __FILE__, __LINE__)
38 #define ne_strndup(s, n) ne_strndup_ml(s, n, __FILE__, __LINE__)
39 #define ne_free ne_free_ml
40 
41 /* Prototypes of allocation functions: */
42 void *ne_malloc_ml(size_t size, const char *file, int line);
43 void *ne_calloc_ml(size_t size, const char *file, int line);
44 void *ne_realloc_ml(void *ptr, size_t s, const char *file, int line);
45 char *ne_strdup_ml(const char *s, const char *file, int line);
46 char *ne_strndup_ml(const char *s, size_t n, const char *file, int line);
47 void ne_free_ml(void *ptr);
48 
49 /* Dump the list of currently allocated blocks to 'f'. */
50 void ne_alloc_dump(FILE *f);
51 
52 /* Current number of bytes in allocated but not free'd. */
53 extern size_t ne_alloc_used;
54 
55 #endif /* MEMLEAK_H */
56