[go: up one dir, main page]

File: dmalloc.h

package info (click to toggle)
libforms 1.2.3-1.3
  • links: PTS
  • area: main
  • in suites: buster, stretch
  • size: 10,736 kB
  • ctags: 9,015
  • sloc: ansic: 97,669; sh: 11,156; makefile: 951
file content (99 lines) | stat: -rw-r--r-- 3,207 bytes parent folder | download | duplicates (7)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
 *
 *  This file is part of the XForms library package.
 *
 * XForms is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1, or
 * (at your option) any later version.
 *
 * XForms 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with XForms. If not, see <http://www.gnu.org/licenses/>.
 */


/**
 * \file dmalloc.h
 *
 *  This file is part of the XForms library package.
 *  Copyright (c) 1996-1998  T.C. Zhao and Mark Overmars
 *  All rights reserved.
 *
 * Very simple debug version of malloc family. It works by replacing the
 * standard malloc and its cousins with  my own routines that track, among
 * other things, where mallocs are called and how many bytes they get. All
 * these relies on the the work of true malloc. A true debug version of
 * malloc should replace malloc with calls to sbrk. Anyway, All I want out of
 * this hack is to make sure there are no memory leaks.
 */

#ifndef TC_DMALLOC_H_
#define TC_DMALLOC_H_

#include <stdlib.h>

#ifdef TC_MEMDBG

extern void *tc_dbg_malloc( size_t,
                            const char *,
                            int );
extern void *tc_dbg_calloc( size_t,
                            size_t,
                            const char *,
                            int );
extern void *tc_dbg_realloc( void *,
                             size_t,
                             const char *,
                             int );
extern void *tc_dbg_getmat( int,
                            int,
                            size_t,
                            const char *,
                            int );
extern char *tc_dbg_strdup( const char *,
                            const char *,
                            int );
extern void tc_dbg_free( void *,
                         const char *,
                         int );
extern void tc_true_free( void * );
extern void tc_set_mem_warn( int );
extern void tc_mem_stat( int );

#ifndef TC_MEMDBG_OWNER     /* actual replacememnt */
#define fl_malloc( a )        tc_dbg_malloc( a, __FILE__, __LINE__ )
#define fl_calloc( a, b )     tc_dbg_calloc( a, b, __FILE__, __LINE__ )
#define fl_realloc( a, b )    tc_dbg_realloc( a, b, __FILE__, __LINE__ )
#define fl_free( a )          tc_dbg_free( a, __FILE__, __LINE__ )
#define fl_strdup( a )        tc_dbg_strdup( a, __FILE__, __LINE__ )
#endif /* TC_MEMDBG_OWNER */

#else /* if not debug, tfree becomes free */

#ifndef fl_free
#define fl_malloc( a )        malloc( a )
#define fl_calloc( a, b )     calloc( a, b )
#define fl_realloc( a, b )    realloc( a, b )
#define fl_free( a )          free( a )
#endif

#define tc_true_free( p )     free( p )
#define tc_mem_stat( a )
#define tc_set_mem_warn( p )

#endif /* TC_MEMDBG */

#endif /* _MY_MALLOC_H */


/*
 * Local variables:
 * tab-width: 4
 * indent-tabs-mode: nil
 * End:
 */