blob: e03d1b364b27a8ef3d64de04afd0293551e04091 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
/*
* 構造体allocator
* ソースコード中ではatorと略することがある
*/
#ifndef _alloc_h_included_
#define _alloc_h_included_
/** アロケータのハンドル */
typedef struct allocator_priv * allocator;
/*
* allocatorを作る
* s: 構造体のsize(バイト数)
* dtor: =destructor 確保したオブジェクトが解放されるときに呼ばれる関数
* dtorの引数は解放されるオブジェクト
* 返り値: 作成したallocator
*/
allocator anthy_create_allocator(int s, void (*dtor)(void *));
/*
* allocatorを解放する
* この際に、このallocatorから確保されたオブジェクトは全て解放される
* a: 解放するallocator
*/
void anthy_free_allocator(allocator a);
/*
* オブジェクトを確保する
* a: allocator
* 返り値: 確保したオブジェクトのアドレス
*/
void *anthy_smalloc(allocator a);
/*
* オブジェクトを解放する
* a: allocator
* p: 解放するオブジェクトのアドレス
*/
void anthy_sfree(allocator a, void *p);
/* 全てのallocatorを破棄する */
void anthy_quit_allocator(void);
#endif
|