提交 16bda0a1 编写于 作者: Y yuqing

mblock add total_count

上级 c8ecbb8c
......@@ -44,6 +44,7 @@ int fast_mblock_init(struct fast_mblock_man *mblock, const int element_size, \
mblock->malloc_chain_head = NULL;
mblock->free_chain_head = NULL;
mblock->total_count = 0;
return 0;
}
......@@ -90,6 +91,7 @@ static int fast_mblock_prealloc(struct fast_mblock_man *mblock)
pMallocNode->next = mblock->malloc_chain_head;
mblock->malloc_chain_head = pMallocNode;
mblock->total_count += mblock->alloc_elements_once;
return 0;
}
......@@ -189,7 +191,7 @@ int fast_mblock_free(struct fast_mblock_man *mblock, \
return 0;
}
int fast_mblock_count(struct fast_mblock_man *mblock)
int fast_mblock_free_count(struct fast_mblock_man *mblock)
{
struct fast_mblock_node *pNode;
int count;
......
......@@ -37,6 +37,7 @@ struct fast_mblock_man
struct fast_mblock_malloc *malloc_chain_head; //malloc chain to be freed
int element_size; //element size
int alloc_elements_once; //alloc elements once
int total_count; //total element count
pthread_mutex_t lock; //the lock for read / write free node chain
};
......@@ -90,7 +91,9 @@ parameters:
mblock: the mblock pointer
return the free node count of the mblock, return -1 if fail
*/
int fast_mblock_count(struct fast_mblock_man *mblock);
int fast_mblock_free_count(struct fast_mblock_man *mblock);
#define fast_mblock_total_count(mblock) (mblock)->total_count
#ifdef __cplusplus
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册