blob: 4b11751ebcc27927085728cbfaa9f33fed8e23fd [file] [log] [blame]
Diederik de Haas9bdc8f02025-03-01 11:14:12 +01001/* SPDX-License-Identifier: LGPL-2.1-or-later */
Eugene Urievf5f24c82024-03-31 23:03:21 +03002/*
3 * Copyright (C) 1996-2024 Free Software Foundation, Inc.
4 * This file is part of the GNU C Library.
Eugene Urievf5f24c82024-03-31 23:03:21 +03005 */
6#ifndef _MCHECK_H
7#define _MCHECK_H 1
8
9/*
10 * Return values for `mprobe': these are the kinds of inconsistencies that
11 * `mcheck' enables detection of.
12 */
13enum mcheck_status {
14 MCHECK_DISABLED = -1, /* Consistency checking is not turned on. */
15 MCHECK_OK, /* Block is fine. */
16 MCHECK_FREE, /* Block freed twice. */
17 MCHECK_HEAD, /* Memory before the block was clobbered. */
18 MCHECK_TAIL /* Memory after the block was clobbered. */
19};
20
Eugene Uriev5d7f16f2024-03-31 23:03:27 +030021typedef void (*mcheck_abortfunc_t)(enum mcheck_status, const void *p);
Eugene Urievf5f24c82024-03-31 23:03:21 +030022
23int mcheck(mcheck_abortfunc_t func);
24
25/*
Eugene Uriev2601b612024-03-31 23:03:24 +030026 * Similar to `mcheck' but performs checks for all block whenever one of
27 * the memory handling functions is called. This can be very slow.
28 */
29int mcheck_pedantic(mcheck_abortfunc_t f);
30
31/* Force check of all blocks now. */
32void mcheck_check_all(void);
33
34/*
Eugene Urievf5f24c82024-03-31 23:03:21 +030035 * Check for aberrations in a particular malloc'd block. These are the
36 * same checks that `mcheck' does, when you free or reallocate a block.
37 */
38enum mcheck_status mprobe(void *__ptr);
39
40#endif