From 292f98dc292a6210cd3d06ef5e246f5abd904ffc Mon Sep 17 00:00:00 2001 From: Erik van der Kouwe Date: Fri, 20 Aug 2010 19:50:36 +0000 Subject: [PATCH] Minor malloc-debug fixes --- lib/libc/ansi/malloc-debug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/libc/ansi/malloc-debug.c b/lib/libc/ansi/malloc-debug.c index ae0420d9b..7b5ffe61e 100644 --- a/lib/libc/ansi/malloc-debug.c +++ b/lib/libc/ansi/malloc-debug.c @@ -126,7 +126,7 @@ static struct block *block_alloc(size_t size) read_tsc_64(&tsc); totalsize = block_get_totalsize(size); page_index_max = (ptr_max - ptr_min - totalsize) / PAGE_SIZE; - page_index = rem64u(tsc, page_index_max); + page_index = (page_index_max > 0) ? (tsc.lo % page_index_max) : 0; ptr = ptr_min + page_index * PAGE_SIZE; /* allocate block */ @@ -143,7 +143,7 @@ static struct block *block_alloc(size_t size) } /* block may not be at the requested location if that is in use */ - if (ptr_min < (u8_t *) block) + if (ptr_min > (u8_t *) block) ptr_min = (u8_t *) block; if (ptr_max < (u8_t *) block) -- 2.44.0