largealloc: rephrase pointer comparison

This commit is contained in:
Nathaniel Filardo 2019-05-09 20:54:15 +01:00
Родитель f7c131e4ac
Коммит 4dd77d35ab
1 изменённых файлов: 8 добавлений и 1 удалений

Просмотреть файл

@ -294,7 +294,14 @@ namespace snmalloc
template<AllowReserve allow_reserve>
bool reserve_memory(size_t need, size_t add)
{
if ((address_cast(reserved_start) + need) > address_cast(reserved_end))
assert(reserved_start <= reserved_end);
/*
* Spell this comparison in terms of pointer subtraction like this,
* rather than "reserved_start + need < reserved_end" because the
* sum might not be representable on CHERI.
*/
if (pointer_diff(reserved_start, reserved_end) < need)
{
if constexpr (allow_reserve == YesReserve)
{