Commit 8999e7ad authored by marko's avatar marko

branches/zip: Simplify the interface to mem0pool.c.

mem_heap_create_block(): Compute len and call mem_area_alloc() only once.

mem_heap_block_free(): Call mem_area_free() only once.

Approved by Heikki.
parent 2b202464
...@@ -330,17 +330,11 @@ mem_heap_create_block( ...@@ -330,17 +330,11 @@ mem_heap_create_block(
} }
/* In dynamic allocation, calculate the size: block header + data. */ /* In dynamic allocation, calculate the size: block header + data. */
if (type == MEM_HEAP_DYNAMIC) {
len = MEM_BLOCK_HEADER_SIZE + MEM_SPACE_NEEDED(n); len = MEM_BLOCK_HEADER_SIZE + MEM_SPACE_NEEDED(n);
block = mem_area_alloc(&len, mem_comm_pool);
} else {
ut_ad(n <= MEM_MAX_ALLOC_IN_BUF);
len = MEM_BLOCK_HEADER_SIZE + MEM_SPACE_NEEDED(n); if (type == MEM_HEAP_DYNAMIC || len < UNIV_PAGE_SIZE / 2) {
if (len < UNIV_PAGE_SIZE / 2) { ut_ad(type == MEM_HEAP_DYNAMIC || n <= MEM_MAX_ALLOC_IN_BUF);
block = mem_area_alloc(&len, mem_comm_pool); block = mem_area_alloc(&len, mem_comm_pool);
} else { } else {
...@@ -364,7 +358,6 @@ mem_heap_create_block( ...@@ -364,7 +358,6 @@ mem_heap_create_block(
block = (mem_block_t*) buf_block->frame; block = (mem_block_t*) buf_block->frame;
} }
}
ut_ad(block); ut_ad(block);
block->buf_block = buf_block; block->buf_block = buf_block;
...@@ -492,19 +485,14 @@ mem_heap_block_free( ...@@ -492,19 +485,14 @@ mem_heap_block_free(
UNIV_MEM_ASSERT_AND_FREE(block, len); UNIV_MEM_ASSERT_AND_FREE(block, len);
#endif /* UNIV_MEM_DEBUG */ #endif /* UNIV_MEM_DEBUG */
if (type == MEM_HEAP_DYNAMIC) { if (type == MEM_HEAP_DYNAMIC || len < UNIV_PAGE_SIZE / 2) {
ut_ad(!buf_block); ut_ad(!buf_block);
mem_area_free(block, mem_comm_pool); mem_area_free(block, mem_comm_pool);
} else { } else {
ut_ad(type & MEM_HEAP_BUFFER); ut_ad(type & MEM_HEAP_BUFFER);
if (len >= UNIV_PAGE_SIZE / 2) {
buf_block_free(buf_block); buf_block_free(buf_block);
} else {
ut_ad(!buf_block);
mem_area_free(block, mem_comm_pool);
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment