__heaprpt() - 動的ヒープ・ストレージ報告書の取得

標準

標準/拡張機能 C/C++ 依存項目

Language Environment®

両方  

形式

#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);

機能説明

__heaprpt() は、アプリケーションのストレージ使用状況に関する 統計を取得し、それを heap_report_structure 引数で ポイントされる領域に置きます。このストレージ報告書は、RPTSTG(ON) ランタイム・オプションで生成されたユーザー・ヒープ報告書と 似た内容になります。

この関数を使用するには、呼び出し元プログラムは ユーザーのヒープ・ストレージ報告書が保管されるストレージを取得する必要があります。 このストレージのアドレスは、引数として __heaprpt() に渡されます。

戻り値

正常に終了した場合、__heaprpt() は、struct hreport_t に、ユーザーのヒープ・ストレージ報告書情報を書き込みます。

アドレスが無効な場合、__heaprpt() は -1 を戻し、errno を EFAULT に設定します。

#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);
  }

}

関連情報