delorie.com/djgpp/doc/libc/libc_554.html | search |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
#include <stdlib.h> int malloc_verify(void); |
This function attempts to determine if the heap has been corrupted. It
scans all the blocks allocated by malloc
and handed to the
application, and also all the free blocks maintained by malloc
and free
in the internal free list. Each block is checked for
consistency of the hidden bookkeeping information recorded in it by
malloc
and free
. The blocks on the free list are
additionally validated by chasing all the next
pointers in the
linked list and checking them against limits for valid pointers (between
0x1000 and the data segment limit), and the alignment. (Unaligned
pointers are probably corrupted, since malloc
always returns a
properly aligned storage.)
What happens when a bad block is found depends on the current malloc diagnostics level: for example, the block can be reported, or the program may be aborted. See section malloc_debug, for the details.
If the program isn't aborted during the function's run (this depends on
the current diagnostics level), malloc_verify
returns 1 if the
heap passes all tests, or zero of some of the tests failed.
ANSI/ISO C | No |
POSIX | No (see note 1) |
Notes:
if (malloc_verify() == 0) printf ("Heap corruption detected!\n"); |
webmaster | delorie software privacy |
Copyright © 2004 | Updated Apr 2004 |