summaryrefslogtreecommitdiff
path: root/src/memleak.h
blob: 8d77dcbaf843fbdabdc980ffbee05f32bf932d5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* 
   Memory leak wrappers
   Copyright (C) 2003, Joe Orton <joe@manyfish.co.uk>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.
   
   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with this library; if not, write to the Free
   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
   MA 02111-1307, USA

*/

/* WARNING: THIS IS AN INTERNAL NEON INTERFACE AND MUST NOT BE USED
 * from NEON APPLICATIONS. */

/* This file contains an alternate interface to the memory allocation
 * wrappers in ne_alloc.c, which perform simple leak detection.  It
 * MUST NOT BE INSTALLED, or used from neon applications. */

#ifndef MEMLEAK_H
#define MEMLEAK_H

#include <stdio.h>

#define ne_malloc(s) ne_malloc_ml(s, __FILE__, __LINE__)
#define ne_calloc(s) ne_calloc_ml(s, __FILE__, __LINE__)
#define ne_realloc(p, s) ne_realloc_ml(p, s, __FILE__, __LINE__)
#define ne_strdup(s) ne_strdup_ml(s, __FILE__, __LINE__)
#define ne_strndup(s, n) ne_strndup_ml(s, n, __FILE__, __LINE__)
#define ne_free ne_free_ml

/* Prototypes of allocation functions: */
void *ne_malloc_ml(size_t size, const char *file, int line);
void *ne_calloc_ml(size_t size, const char *file, int line);
void *ne_realloc_ml(void *ptr, size_t s, const char *file, int line);
char *ne_strdup_ml(const char *s, const char *file, int line);
char *ne_strndup_ml(const char *s, size_t n, const char *file, int line);
void ne_free_ml(void *ptr);

/* Dump the list of currently allocated blocks to 'f'. */
void ne_alloc_dump(FILE *f);

/* Current number of bytes in allocated but not free'd. */
extern size_t ne_alloc_used;

#endif /* MEMLEAK_H */