From: Erik van der Kouwe Date: Fri, 20 Aug 2010 19:50:36 +0000 (+0000) Subject: Minor malloc-debug fixes X-Git-Tag: v3.1.8~60 X-Git-Url: http://zhaoyanbai.com/repos/cppcheck.log?a=commitdiff_plain;h=292f98dc292a6210cd3d06ef5e246f5abd904ffc;p=minix.git Minor malloc-debug fixes --- 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)