picox
0.1
|
#include <picox/allocator/xpico_allocator.h>
マクロ定義 | |
#define | X__ALIGN (self->alignment) |
関数 | |
static void * | X__Allocate (XPicoAllocator *self, size_t size) |
static void | X__Deallocate (XPicoAllocator *self, void *ptr, size_t size) |
void * | xpalloc_allocate (XPicoAllocator *self, size_t size) |
size_t | xpalloc_allocation_overhead (const XPicoAllocator *self, size_t n) |
void | xpalloc_clear (XPicoAllocator *self) |
void | xpalloc_deallocate (XPicoAllocator *self, void *ptr) |
void | xpalloc_deinit (XPicoAllocator *self) |
bool | xpalloc_init (XPicoAllocator *self, void *heap, size_t size, size_t alignment) |
bool | xpalloc_is_owner (const XPicoAllocator *self, const void *ptr) |
void * | xpalloc_reallocate (XPicoAllocator *self, void *old_mem, size_t new_size) |
void | xpalloc_walk_heap (const XPicoAllocator *self, XPicoAllocatorWalker walker, void *user) |
void* xpalloc_allocate | ( | XPicoAllocator * | self, |
size_t | size | ||
) |
ヒープからsizeバイトのメモリを切り出して返します
size_t xpalloc_allocation_overhead | ( | const XPicoAllocator * | self, |
size_t | n | ||
) |
nバイトのメモリ確保を行った場合に必要な余分なメモリサイズを返します。
void xpalloc_clear | ( | XPicoAllocator * | self | ) |
ヒープを初期状態に戻します
void xpalloc_deallocate | ( | XPicoAllocator * | self, |
void * | ptr | ||
) |
ヒープにメモリを返却します
void xpalloc_deinit | ( | XPicoAllocator * | self | ) |
オブジェクトの終了処理を行います
bool xpalloc_init | ( | XPicoAllocator * | self, |
void * | heap, | ||
size_t | size, | ||
size_t | alignment | ||
) |
メモリブロックを初期化します
heap | heapとして利用するメモリ領域 |
size | heap領域のサイズ |
alignment | allocatorが返すメモリアドレスのアライメント |
heap == NULLの場合はsizeバイトのメモリをx_malloc()で確保します。
true | 初期化成功 |
false | メモリ確保失敗 |
alignmentには特殊なアラインメントが必要な時以外はX_ALIGN_OF(XMaxAlign)を指定 しておくのが無難です。例えば文字列等のバイトデータしか扱わないということがわ かっているなら、アライメントを1とすることができますが、管理データの格納用に 内部的には最低でもX_ALIGN_OF(size_t)まで、切り上げが行われます。
bool xpalloc_is_owner | ( | const XPicoAllocator * | self, |
const void * | ptr | ||
) |
ポインタがヒープ領域の範囲内かどうかを返します。
void* xpalloc_reallocate | ( | XPicoAllocator * | self, |
void * | old_mem, | ||
size_t | size | ||
) |
realloc()相当の処理を行います
void xpalloc_walk_heap | ( | const XPicoAllocator * | self, |
XPicoAllocatorWalker | walker, | ||
void * | user | ||
) |
ヒープ内の空きブロックを走査し、ブロックごとにwalkerを呼び出します
デバッグ用です。walkerがデータを収集することで、断片化状況等を確認できます。
walker | 空きブロック検出毎に呼び出される関数 |
user | walker呼び出し時に渡されるポインタ |