diff options
author | Chris Robinson <[email protected]> | 2019-01-11 20:06:23 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-01-11 20:06:23 -0800 |
commit | 77447fcd542d0e27b0e19caa666c0246c0cb05d2 (patch) | |
tree | a4ee0167c1bbd45209ee5fa5ecfa4ec7fec3a909 /common/almalloc.h | |
parent | 852c5005ab0b4709a6efa125146b01902950d273 (diff) |
Add placement operator delete
Diffstat (limited to 'common/almalloc.h')
-rw-r--r-- | common/almalloc.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/common/almalloc.h b/common/almalloc.h index cc46f144..166ac8c9 100644 --- a/common/almalloc.h +++ b/common/almalloc.h @@ -34,7 +34,8 @@ int al_is_sane_alignment_allocator(void) noexcept; #define DEF_PLACE_NEWDEL() \ void *operator new(size_t /*size*/, void *ptr) noexcept { return ptr; } \ - void operator delete(void *block) noexcept { al_free(block); } + void operator delete(void *block) noexcept { al_free(block); } \ + void operator delete(void* /*block*/, void* /*ptr*/) noexcept { } namespace al { @@ -101,8 +102,11 @@ struct FlexArray { const size_t mSize; alignas(alignment) T mArray[]; - static constexpr size_t CalcSizeof(size_t count) noexcept - { return std::max<size_t>(offsetof(FlexArray, mArray) + sizeof(T)*count, sizeof(FlexArray)); } + static constexpr size_t Sizeof(size_t count, size_t base=0u) noexcept + { + return base + + std::max<size_t>(offsetof(FlexArray, mArray) + sizeof(T)*count, sizeof(FlexArray)); + } FlexArray(size_t size) : mSize{size} { new (mArray) T[mSize]; } |