测试内存池

This commit is contained in:
1iaan
2026-01-31 15:38:52 +00:00
parent fbdcff6878
commit 003566b69a
29 changed files with 614 additions and 233 deletions

View File

@@ -74,7 +74,7 @@ static mp_page_t* mp_page_create(mp_bucket_t *owner){
pg->prev = NULL;
pg->next = NULL;
bitmap_clear_all(pg->bitmap, 20);
bitmap_clear_all(pg->bitmap, 16);
char *p = (char*)page_payload(pg);
for(uint16_t i = 0;i < cap - 1; ++ i){
@@ -313,4 +313,18 @@ int mp_free(mp_pool_t *pool, void *ptr){
}
return 0;
}
int mp_print(mp_pool_t *pool){
int ret = 0;
printf("------\n");
for(int i = 0; i < MEMPOOL_NUM_CLASSES; i++){
mp_bucket_t *bucket = &pool->buckets[i];
if(bucket->page_count) ret += bucket->page_count;
printf("size:%ld, page:%d, empty:%d\n", bucket->block_size, bucket->page_count, bucket->empty_count);
}
printf("------\n");
printf("page count: %d\n", ret);
return ret;
}