From 5520dae2e795dc9a2f38e7e6076a79dcac2b2e7f Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Tue, 20 Apr 2021 12:16:43 +0200 Subject: Another small change to custommem MaxFreeblock handling --- src/custommem.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/custommem.c b/src/custommem.c index 80adb476..8bc25ac0 100644 --- a/src/custommem.c +++ b/src/custommem.c @@ -97,14 +97,12 @@ static size_t getMaxFreeBlock(void* block, size_t block_size) while(m->prev.x32) { // while there is a subblock if(!m->prev.fill && m->prev.size>maxsize) { maxsize = m->prev.size; - if(maxsize>sizeof(blockmark_t)) - maxsize -= sizeof(blockmark_t); if((uintptr_t)block+maxsize>(uintptr_t)m) - return maxsize; // no block large enough left... + return (maxsize>=sizeof(blockmark_t))?(maxsize-sizeof(blockmark_t)):0; // no block large enough left... } m = (blockmark_t*)((uintptr_t)m - m->prev.size); } - return maxsize; + return (maxsize>=sizeof(blockmark_t))?(maxsize-sizeof(blockmark_t)):0; } static void* allocBlock(void* block, void *sub, size_t size) -- cgit 1.4.1