get_malloc_log Subroutine

Purpose

Retrieves information about the malloc subsystem.

Syntax

#include <malloc.h>
size_t get_malloc_log (addr, buf, bufsize)
void *addr;
void *buf;
size_t bufsize;

Description

The get_malloc_log subroutine retrieves a record of currently active malloc allocations. These records are stored as an array of malloc_log structures, which are copied from the process heap into the buffer specified by the buf parameter. No more than bufsize bytes are copied into the buffer. Only records corresponding to the heap of which addr is a member are copied, unless addr is NULL, in which case records from all heaps are copied. The addr parameter must be either a pointer to space allocated previously by the malloc subsystem or NULL.

Parameters

Item Description
addr Pointer to a space allocated by the malloc subsystem.
buf Specifies into which buffer the malloc_log structures are stored.
bufsize Specifies the number of bytes that can be copied into the buffer.

Return Values

The get_malloc_log subroutine returns the number of bytes actually transferred into the bufsize parameter. If Malloc Log is not enabled, 0 is returned. If addr is not a pointer allocated by the malloc subsystem, 0 is returned and the errno global variable is set to EINVAL.