高速ヒープ領域 [FastHeap]

1. 目次


2. ◆ 高速ヒープ領域の使い方

高速ヒープ領域は、確保するメモリサイズを固定にすることで 高速化を行っています。そのため、 malloc / free する型ごとにヒープ領域を宣言する必要があります。 また、malloc / free するたびに、型を指定する必要があります。

FastHeap_Mem  FastHeap_Type_mem;    /* Type 型ヒープ領域 */
FastHeap_Mem  FastHeap_Data_mem;    /* Data 型ヒープ領域 */

void  init()
{
  FastHeap_Book_init( &FastHeap_Type_mem, adr, size, Type );
  FastHeap_Book_init( &FastHeap_Data_mem, adr, size, Data );
}

void  run()
{
  Type*  type;
  Data*  data;

  init();

  fast_malloc( &type, Type );
  fast_malloc( &data, Data );

  fast_free( type, Type );
  fast_free( data, Data );
}


3. ◆ 高速ヒープ領域のメモリ領域を管理する登録簿 の使い方

あるオブジェクトの管理下にあるヒープ領域は、 malloc / free する型ごとにヒープ領域をオブジェクトのメンバ変数に 宣言する必要があります。 また、malloc / free するたびに、ヒープ領域変数名と型を指定する必要があります。

class  Manager {
  int   attr;

  FastHeap_Book  types;    /* Type 型ヒープ領域 */
  FastHeap_Book  datas;    /* Data 型ヒープ領域 */
};

void  Manager_init()
{
  FastHeap_Book_init( &this->types, adr, size, Type );
  FastHeap_Book_init( &this->dtatas, adr, size, Data );
}

void  run()
{
  Type*  type;
  Data*  data;
  Manager  m;

  Manager_init();

  fast_malloc( &type, &m->types, Type );
  fast_malloc( &data, &m->datas, Data );

  fast_free( type, &m->types, Type );
  fast_free( data, &m->datas, Data );
}


written by Masanori Toda