Skip to content

Commit 69a7591

Browse files
committed
Fix computing ptr and update pool_size
Fix computing ptr and update pool_size after freeing most of the first pool. The first (main) pool has just been freed except of the first page containing the metadata. The pool size has to be updated and set to the size of one page. Signed-off-by: Lukasz Dorau <[email protected]>
1 parent f5ccca4 commit 69a7591

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/base_alloc/base_alloc_linear.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,11 @@ int umf_ba_linear_free(umf_ba_linear_pool_t *pool, void *ptr) {
199199
if ((pool->metadata.pool_n_allocs == 0) && pool->next_pool &&
200200
(pool->metadata.pool_size > page_size)) {
201201
// we can free the first (main) pool except of the first page containing the metadata
202-
void *ptr = pool + page_size;
202+
void *ptr = (char *)pool + page_size;
203203
size_t size = pool->metadata.pool_size - page_size;
204204
ba_os_free(ptr, size);
205+
// update pool_size
206+
pool->metadata.pool_size = page_size;
205207
}
206208
DEBUG_RUN_CHECKS(pool);
207209
util_mutex_unlock(&pool->metadata.lock);

0 commit comments

Comments
 (0)