/*
*
*
*/
#include "mem.h"
MEM_POOL g_stMemPool;
/***************************Begin of Memory Pool Section********************************/
/* @x : size of memory block (32 /64 /.../256....)
* @tpblk: ptr to MEM_BLK used as temporary storage
*/
#define MEMPOOL_ALLOC(x, tpblk) BUCKET_ALLOC(&(g_stMemPool.m_bucket##x), tpblk)
/* @x : size of memory block (32 /64 /.../256....)
* @pdata : ptr to data member of struct _memBlk
*/
#define MEMPOOL_FREE(x, pdata) BUCKET_FREE(&(g_stMemPool.m_bucket##x), pdata)
/* @x : size of memory block (32 /64 /.../256....)
* @n : number of malloced memory blocks
*/
#define MEMPOOL_INIT(x, n) { BUCKET_INIT(&(g_stMemPool.m_bucket##x), x, n);\
g_stMemPool.ulTotalSize += (n)*
常用内存池的实现 mem.c
最新推荐文章于 2023-11-07 17:27:38 发布