]> git.ipfire.org Git - thirdparty/glibc.git/blob - malloc/mcheck.h
Update from main archive 961219
[thirdparty/glibc.git] / malloc / mcheck.h
1 /* Copyright (C) 1996 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
18
19 #ifndef _MCHECK_H
20 #define _MCHECK_H 1
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 #if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
27 #undef __P
28 #define __P(args) args
29 #undef __ptr_t
30 #define __ptr_t void *
31 #else /* Not C++ or ANSI C. */
32 #undef __P
33 #define __P(args) ()
34 #undef __ptr_t
35 #define __ptr_t char *
36 #endif /* C++ or ANSI C. */
37
38
39 /* Return values for `mprobe': these are the kinds of inconsistencies that
40 `mcheck' enables detection of. */
41 enum mcheck_status
42 {
43 MCHECK_DISABLED = -1, /* Consistency checking is not turned on. */
44 MCHECK_OK, /* Block is fine. */
45 MCHECK_FREE, /* Block freed twice. */
46 MCHECK_HEAD, /* Memory before the block was clobbered. */
47 MCHECK_TAIL /* Memory after the block was clobbered. */
48 };
49
50
51 /* Activate a standard collection of debugging hooks. This must be called
52 before `malloc' is ever called. ABORTFUNC is called with an error code
53 (see enum above) when an inconsistency is detected. If ABORTFUNC is
54 null, the standard function prints on stderr and then calls `abort'. */
55 extern int mcheck __P ((void (*__abortfunc) __P ((enum mcheck_status))));
56
57 /* Check for aberrations in a particular malloc'd block. You must have
58 called `mcheck' already. These are the same checks that `mcheck' does
59 when you free or reallocate a block. */
60 extern enum mcheck_status mprobe __P ((__ptr_t __ptr));
61
62 /* Activate a standard collection of tracing hooks. */
63 extern void mtrace __P ((void));
64 extern void muntrace __P ((void));
65
66 #ifdef __cplusplus
67 }
68 #endif
69
70 #endif /* mcheck.h */