Minor malloc-debug fixes

This commit is contained in:
Erik van der Kouwe 2010-08-20 19:50:36 +00:00
parent 2a736d0c2e
commit 292f98dc29

View File

@ -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)