最終更新:ID:D7J/gPk67w 2009年02月08日(日) 02:34:55履歴
/* Allocate a block of the requested size, to be passed to [caml_add_to_heap] later. [request] must be a multiple of [Page_size]. [caml_alloc_for_heap] returns NULL if the request cannot be satisfied. The returned pointer is a hp, but the header must be initialized by the caller. */
後でocaml-3.11.0/caml_add_to_heapに渡すため、要求された大きさのブロックをアロケートする。requestはPage_sizeの倍数でなければならない。要求が満たされなかった場合、caml_alloc_for_heapはNULLを返す。返すポインタはhpであるが、ヘッダは呼び出し側が初期化しなければならない。
char *caml_alloc_for_heap (asize_t request) { char *mem; void *block; Assert (request % Page_size == 0);
mem = caml_aligned_malloc (request + sizeof (heap_chunk_head), sizeof (heap_chunk_head), &block);
チャンクとヘッダをアロケートする。
if (mem == NULL) return NULL; mem += sizeof (heap_chunk_head);
変数memの値が、チャンクへのポインタとなる。
Chunk_size (mem) = request;
Chunk_block (mem) = block;
return mem; }
タグ
コメントをかく