Add DEBUG constexpr
Enable checking use of a constexpr rather than ifdef for checking if in DEBUG.
This commit is contained in:
committed by
Matthew Parkinson
parent
f1be609cdb
commit
3d1b973480
@@ -113,9 +113,8 @@ namespace snmalloc
|
||||
{
|
||||
SNMALLOC_ASSERT(is_aligned_block<page_size>(p, size));
|
||||
|
||||
# if !defined(NDEBUG)
|
||||
memset(p, 0x5a, size);
|
||||
# endif
|
||||
if constexpr (DEBUG)
|
||||
memset(p, 0x5a, size);
|
||||
|
||||
// `MADV_FREE_REUSABLE` can only be applied to writable pages,
|
||||
// otherwise it's an error.
|
||||
|
||||
@@ -35,9 +35,9 @@ namespace snmalloc
|
||||
{
|
||||
SNMALLOC_ASSERT(is_aligned_block<OS::page_size>(p, size));
|
||||
|
||||
#if !defined(NDEBUG)
|
||||
memset(p, 0x5a, size);
|
||||
#endif
|
||||
if constexpr (DEBUG)
|
||||
memset(p, 0x5a, size);
|
||||
|
||||
madvise(p, size, MADV_FREE);
|
||||
|
||||
if constexpr (PalEnforceAccess)
|
||||
|
||||
@@ -70,11 +70,11 @@ namespace snmalloc
|
||||
|
||||
if constexpr (PalEnforceAccess)
|
||||
{
|
||||
# if !defined(NDEBUG)
|
||||
// Fill memory so that when we switch the pages back on we don't make
|
||||
// assumptions on the content.
|
||||
memset(p, 0x5a, size);
|
||||
# endif
|
||||
if constexpr (DEBUG)
|
||||
memset(p, 0x5a, size);
|
||||
|
||||
madvise(p, size, MADV_FREE);
|
||||
mprotect(p, size, PROT_NONE);
|
||||
}
|
||||
|
||||
@@ -189,11 +189,11 @@ namespace snmalloc
|
||||
|
||||
if constexpr (PalEnforceAccess)
|
||||
{
|
||||
#if !defined(NDEBUG)
|
||||
// Fill memory so that when we switch the pages back on we don't make
|
||||
// assumptions on the content.
|
||||
memset(p, 0x5a, size);
|
||||
#endif
|
||||
if constexpr (DEBUG)
|
||||
memset(p, 0x5a, size);
|
||||
|
||||
mprotect(p, size, PROT_NONE);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user