Skip to content

Commit

Permalink
Do not clamp pool indices to POOL_COUNT (#2067)
Browse files Browse the repository at this point in the history
The current pool allocator algorithms can work with pool indices
greater than POOL_COUNT. Allowing such indices allows us to remove a
conditional in ponyint_pool_index.
  • Loading branch information
Benoit Vey authored and Theodus committed Jul 20, 2017
1 parent 392bca6 commit 8d68d97
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/libponyrt/mem/pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ void* ponyint_pool_realloc_size(size_t old_size, size_t new_size, void* p)
} else {
size_t new_adj_size = ponyint_pool_adjust_size(new_size);

if(old_index == POOL_COUNT)
if(old_index >= POOL_COUNT)
{
old_adj_size = ponyint_pool_adjust_size(old_size);

Expand Down Expand Up @@ -1058,9 +1058,6 @@ size_t ponyint_pool_index(size_t size)
if(size <= POOL_MIN)
return 0;

if(size > POOL_MAX)
return POOL_COUNT;

#ifdef PLATFORM_IS_ILP32
#define BITS (32 - POOL_MIN_BITS)
#else
Expand Down

0 comments on commit 8d68d97

Please sign in to comment.