ds/address: add pointer diff function
And use it rather than open-coding subtraction of two address_cast-s.
This commit is contained in:
@@ -125,8 +125,7 @@ namespace snmalloc
|
||||
uint16_t pointer_to_index(void* p)
|
||||
{
|
||||
// Get the offset from the slab for a memory location.
|
||||
return static_cast<uint16_t>(
|
||||
((address_cast(p) - address_cast(this))) >> 8);
|
||||
return static_cast<uint16_t>(pointer_diff(this, p) >> 8);
|
||||
}
|
||||
};
|
||||
} // namespace snmalloc
|
||||
|
||||
Reference in New Issue
Block a user