aboutsummaryrefslogtreecommitdiffstats
path: root/vespamalloc
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-06-09 12:41:04 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-06-09 12:41:04 +0000
commit1ab52f43ca7877c08b93408d7bcf8b0355c007e4 (patch)
tree7ce04df0b5f456adde55ffd8ab7aedf1ec8e5478 /vespamalloc
parenta3b94caca5d92adc8330f22d0cb952d81cbc5dbc (diff)
Add some constexpr
Diffstat (limited to 'vespamalloc')
-rw-r--r--vespamalloc/src/vespamalloc/malloc/memblockboundscheck.h22
1 files changed, 11 insertions, 11 deletions
diff --git a/vespamalloc/src/vespamalloc/malloc/memblockboundscheck.h b/vespamalloc/src/vespamalloc/malloc/memblockboundscheck.h
index 7176a83812b..5906203d194 100644
--- a/vespamalloc/src/vespamalloc/malloc/memblockboundscheck.h
+++ b/vespamalloc/src/vespamalloc/malloc/memblockboundscheck.h
@@ -59,10 +59,10 @@ protected:
void verifyFill() const __attribute__((noinline));
void setSize(size_t sz) { static_cast<uint64_t *>(_ptr)[0] = sz; }
- static size_t preambleOverhead(std::align_val_t alignment) {
- return std::max(4*sizeof(unsigned), size_t(alignment));
+ static constexpr size_t preambleOverhead(std::align_val_t alignment) {
+ return std::max(preambleOverhead(), size_t(alignment));
}
- static size_t preambleOverhead() {
+ static constexpr size_t preambleOverhead() {
return 4*sizeof(unsigned);
}
@@ -141,24 +141,24 @@ public:
}
return StackTraceLen;
}
- static size_t adjustSize(size_t sz) { return sz + overhead(); }
- static size_t adjustSize(size_t sz, std::align_val_t alignment) { return sz + overhead(alignment); }
- static size_t unAdjustSize(size_t sz) { return sz - overhead(); }
+ static constexpr size_t adjustSize(size_t sz) { return sz + overhead(); }
+ static constexpr size_t adjustSize(size_t sz, std::align_val_t alignment) { return sz + overhead(alignment); }
+ static constexpr size_t unAdjustSize(size_t sz) { return sz - overhead(); }
static void dumpInfo(size_t level) __attribute__((noinline));
- static size_t getMinSizeForAlignment(size_t align, size_t sz) { return sz + align; }
+ static constexpr size_t getMinSizeForAlignment(size_t align, size_t sz) { return sz + align; }
void info(FILE * os, unsigned level=0) const __attribute__((noinline));
protected:
- static size_t postambleOverhead() {
+ static constexpr size_t postambleOverhead() {
return sizeof(unsigned) + StackTraceLen*sizeof(void *);
}
- static size_t overhead() {
+ static constexpr size_t overhead() {
return preambleOverhead() + postambleOverhead();
}
- static size_t overhead(std::align_val_t alignment) {
+ static constexpr size_t overhead(std::align_val_t alignment) {
return preambleOverhead(alignment) + postambleOverhead();
}
- void setTailMagic() { *(reinterpret_cast<unsigned *> ((char*)_ptr + size() + 4*sizeof(unsigned) + StackTraceLen*sizeof(void *))) = TAIL_MAGIC; }
+ void setTailMagic() { *(reinterpret_cast<unsigned *> ((char*)_ptr + size() + preambleOverhead() + StackTraceLen*sizeof(void *))) = TAIL_MAGIC; }
void init(size_t sz) {
if (_ptr) {
setSize(sz);