COHERENT manpages

This page displays the COHERENT manpage for memok() [Test if the arena is corrupted].

List of available manpages
Index


memok() -- General Function (libc)

Test if the arena is corrupted
int
memok();

The library function memok() checks to see if the arena has been corrupted.
It returns one if the arena is sound, and zero if it has been corrupted.

Example

The following example purposely corrupts the arena, to demonstrate memok().
Please note that this is not a recommended programming practice.

extern char *malloc();
main()
{
    char *p;

     p = malloc(2);           /* get 2 bytes of memory */
     printf("Arena is %s\n", memok() ? "OK" : "bad");
     strcpy(p, "too long");   /* clobber memory */
     printf("Arena is %s\n", memok() ? "OK" : "bad");
}

See Also

arena,
calloc(),
libc,
malloc(),
realloc()