__heaprpt() — Obtain dynamic heap storage report

Standards

Standards / Extensions C or C++ Dependencies

Language Environment

both  

Format

#include <stdlib.h>

typedef struct{long __uheap_size;
               long __uheap_bytes_alloc;
               long __uheap_bytes_free;
              } hreport_t;

int __heaprpt(hreport_t *heap_report_structure);

General description

__heaprpt() gets statistics about the application's storage utilization and places them in the area pointed to by the heap_report_structure argument. The storage report is similar in content to the user heap storage report that is generated with the RPTSTG(ON) runtime option.

To use this function, the calling program must obtain storage where the user's heap storage report will be stored. The address of this storage is passed as an argument to __heaprpt().

Returned value

If successful, __heaprpt() fills the struct hreport_t with the user's heap storage report information.

If the address is not valid, __heaprpt() returns -1 and sets errno to EFAULT.

Example

#include <stdlib.h>
#include <stdio.h>

int main(void)
{
  hreport_t * strptr;

  strptr = (hreport_t *) malloc(sizeof(hreport_t));

  if (__heaprpt(strptr) != 0)
     perror("__heaprpt() error");

  else
  {
     printf("Total amount of user heap storage    : %ld\n",
            strptr->__uheap_size);
     printf("Amount of user heap storage in use   : %ld\n",
            strptr->__uheap_bytes_alloc);
     printf("Amount of available user heap storage: %ld\n",
            strptr->__uheap_bytes_free);
  }

}

Related information