/* Standard debugging hooks for `malloc'.
- Copyright (C) 1990-1997, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1990-1997, 1999, 2000, 2001 Free Software Foundation, Inc.
Written May 1989 by Mike Haertel.
This library is free software; you can redistribute it and/or
return status;
}
-static void check_all __P ((void));
-static void
-check_all ()
+void
+mcheck_check_all ()
{
/* Walk through all the active blocks and test whether they were tempered
with. */
const __ptr_t caller;
{
if (pedantic)
- check_all ();
+ mcheck_check_all ();
if (ptr)
{
struct hdr *hdr = ((struct hdr *) ptr) - 1;
struct hdr *hdr;
if (pedantic)
- check_all ();
+ mcheck_check_all ();
__malloc_hook = old_malloc_hook;
if (old_malloc_hook != NULL)
__malloc_size_t osize;
if (pedantic)
- check_all ();
+ mcheck_check_all ();
if (ptr)
{
return (__ptr_t) (hdr + 1);
}
-static void mabort __P ((enum mcheck_status status));
+static void mabort __P ((enum mcheck_status status))
+ __attribute__ ((noreturn));
static void
mabort (status)
enum mcheck_status status;
/* These hooks may not be safely inserted if malloc is already in use. */
if (__malloc_initialized <= 0 && !mcheck_used)
{
+ /* We call malloc() once here to ensure it is initialized. */
+ void *p = malloc (0);
+ free (p);
+
old_free_hook = __free_hook;
__free_hook = freehook;
old_malloc_hook = __malloc_hook;
mcheck_pedantic (func)
void (*func) __P ((enum mcheck_status));
{
- pedantic = 1;
- return mcheck (func);
+ int res = mcheck (func);
+ if (res == 0)
+ pedantic = 1;
+ return res;
}
enum mcheck_status