Merge pull request #103 from wqfish/dev

Fix the bug that causes not allocating free run with lowest address.

This fixes a regression due to f9ff60346d,
which was never incorporated into a release.
This commit is contained in:
Jason Evans 2014-08-06 17:20:09 -07:00
commit 7f944aa621

View File

@ -101,14 +101,22 @@ arena_avail_comp(arena_chunk_map_t *a, arena_chunk_map_t *b)
uintptr_t a_mapelm = (uintptr_t)a; uintptr_t a_mapelm = (uintptr_t)a;
uintptr_t b_mapelm = (uintptr_t)b; uintptr_t b_mapelm = (uintptr_t)b;
if (a_mapelm & CHUNK_MAP_KEY) if (a_mapelm & CHUNK_MAP_KEY)
a_size = a_mapelm & ~PAGE_MASK; a_size = a_mapelm & ~PAGE_MASK;
else else
a_size = arena_mapelm_to_bits(a) & ~PAGE_MASK; a_size = arena_mapelm_to_bits(a) & ~PAGE_MASK;
ret = (a_size > b_size) - (a_size < b_size); ret = (a_size > b_size) - (a_size < b_size);
if (ret == 0 && (!(a_mapelm & CHUNK_MAP_KEY))) if (ret == 0) {
ret = (a_mapelm > b_mapelm) - (a_mapelm < b_mapelm); if (!(a_mapelm & CHUNK_MAP_KEY))
ret = (a_mapelm > b_mapelm) - (a_mapelm < b_mapelm);
else {
/*
* Treat keys as if they are lower than anything else.
*/
ret = -1;
}
}
return (ret); return (ret);
} }