mcheck.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, write to the Free
  13. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  14. 02111-1307 USA. */
  15. #ifndef _MCHECK_H
  16. #define _MCHECK_H 1
  17. #include <features.h>
  18. __BEGIN_DECLS
  19. /* Return values for `mprobe': these are the kinds of inconsistencies that
  20. `mcheck' enables detection of. */
  21. enum mcheck_status
  22. {
  23. MCHECK_DISABLED = -1, /* Consistency checking is not turned on. */
  24. MCHECK_OK, /* Block is fine. */
  25. MCHECK_FREE, /* Block freed twice. */
  26. MCHECK_HEAD, /* Memory before the block was clobbered. */
  27. MCHECK_TAIL /* Memory after the block was clobbered. */
  28. };
  29. /* Activate a standard collection of debugging hooks. This must be called
  30. before `malloc' is ever called. ABORTFUNC is called with an error code
  31. (see enum above) when an inconsistency is detected. If ABORTFUNC is
  32. null, the standard function prints on stderr and then calls `abort'. */
  33. extern int mcheck (void (*__abortfunc) (enum mcheck_status)) __THROW;
  34. /* Similar to `mcheck´ but performs checks for all block whenever one of
  35. the memory handling functions is called. This can be very slow. */
  36. extern int mcheck_pedantic (void (*__abortfunc) (enum mcheck_status)) __THROW;
  37. /* Force check of all blocks now. */
  38. extern void mcheck_check_all (void);
  39. /* Check for aberrations in a particular malloc'd block. You must have
  40. called `mcheck' already. These are the same checks that `mcheck' does
  41. when you free or reallocate a block. */
  42. extern enum mcheck_status mprobe (void *__ptr) __THROW;
  43. /* Activate a standard collection of tracing hooks. */
  44. extern void mtrace (void) __THROW;
  45. extern void muntrace (void) __THROW;
  46. __END_DECLS
  47. #endif /* mcheck.h */