Memory Allocation Routines


malloc_memcheck, mt_malloc_memcheck


Syntax

#include <malloc.h>
int malloc_memcheck(struct malloc_status_st *st)
int mt_malloc_memcheck(struct malloc_status_st *st)

Arguments

st      pointer to the malloc_status_st structure that returns
        information about the memory allocation area

Return Value

0 is returned if the function execution was normal. In case of any value
other than 0, the contents of the malloc_status_st structure are suspect
and probably incorrect. For example, if 0 is returned, the size of the entire
memory allocation area is recorded in the specified malloc_status_st
structure. However, if the size of the entire memory allocation area is
reported as 0 in the malloc_status_st structure, then the malloc_status_st
contents are incorrect, so the function returns -1 instead of 0. 

Description

It checks the memory allocation area to see if its condition is normal or abnormal, and acquires information on the used and unused portions of the memory allocation area.

mt_malloc_memcheck is the multi-thread compatible version of malloc_memcheck. Interruption is inhibited when processing is being performed to prevent malfunction if used by more than one thread.

struct  malloc_status_st    {
    int     allMemSize;     /*  size of entire memory area      */

    int     useMemSize;     /*  memory size used                */
    int     useMaxMemSize;  /*  maximum memory size used        */
    int     useMinMemSize;  /*  minimum memory size used        */

    int     freeMemSize;    /*  free memory size                */
    int     freeMaxMemSize; /*  minimum free memory size        */
    int     freeMinMemSize; /*  maximum free memory size        */
};


Revision History

6/1/99 Added explanation of the multi-thread version