NFC: Introduce and switch to pal_zero
This wrapper will allow us to pass `AuthPtr<T,B> p` to zero() without needing to write `p.unsafe_auth_ptr` to get to a `T*` inside. Moreover, it will give us a convenient point to assert that `B` is such that the pointer can be used to manipulate the memory map (i.e. is not exported).
This commit is contained in:
committed by
Nathaniel Wesley Filardo
parent
4cfcf344fc
commit
7f841ff081
@@ -69,6 +69,16 @@ namespace snmalloc
|
||||
// Used to keep Superslab metadata committed.
|
||||
static constexpr size_t OS_PAGE_SIZE = Pal::page_size;
|
||||
|
||||
/**
|
||||
* A centralized, inlinable wrapper around PAL::zero. This will matter more
|
||||
* when we introduce AuthPtr-s.
|
||||
*/
|
||||
template<typename PAL, bool page_aligned = false>
|
||||
static SNMALLOC_FAST_PATH void pal_zero(void* p, size_t sz)
|
||||
{
|
||||
PAL::template zero<page_aligned>(p, sz);
|
||||
}
|
||||
|
||||
static_assert(
|
||||
bits::is_pow2(OS_PAGE_SIZE), "OS_PAGE_SIZE must be a power of two");
|
||||
static_assert(
|
||||
|
||||
Reference in New Issue
Block a user