blob: a049745e4e34d863ddc83e52ef3a485cdd48ae41 [file] [log] [blame]
Eugene Urievf5f24c82024-03-31 23:03:21 +03001/* SPDX-License-Identifier: GPL-2.1+ */
2/*
3 * Copyright (C) 1996-2024 Free Software Foundation, Inc.
4 * This file is part of the GNU C Library.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 * <https://www.gnu.org/licenses/>.
16 */
17#ifndef _MCHECK_H
18#define _MCHECK_H 1
19
20/*
21 * Return values for `mprobe': these are the kinds of inconsistencies that
22 * `mcheck' enables detection of.
23 */
24enum mcheck_status {
25 MCHECK_DISABLED = -1, /* Consistency checking is not turned on. */
26 MCHECK_OK, /* Block is fine. */
27 MCHECK_FREE, /* Block freed twice. */
28 MCHECK_HEAD, /* Memory before the block was clobbered. */
29 MCHECK_TAIL /* Memory after the block was clobbered. */
30};
31
32typedef void (*mcheck_abortfunc_t)(enum mcheck_status);
33
34int mcheck(mcheck_abortfunc_t func);
35
36/*
37 * Check for aberrations in a particular malloc'd block. These are the
38 * same checks that `mcheck' does, when you free or reallocate a block.
39 */
40enum mcheck_status mprobe(void *__ptr);
41
42#endif