diff options
author | Chris Robinson <[email protected]> | 2018-11-22 07:06:42 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-11-22 07:06:42 -0800 |
commit | ba8c865513d33019962a02e00ab496365de17abf (patch) | |
tree | 3ee05abc7044873f316003514e0aa0213cc1a41c /common/almalloc.h | |
parent | ab6db9a589ac5ad8daa498e9fedb4de66cbb1948 (diff) |
Add and use a macro to define placement-new-only allocators
This is for structs that utilize over-allocation, either flexible array
members, or which store optional additional objects in the same allocation
block.
Diffstat (limited to 'common/almalloc.h')
-rw-r--r-- | common/almalloc.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/common/almalloc.h b/common/almalloc.h index ccaa6a98..d9b285fe 100644 --- a/common/almalloc.h +++ b/common/almalloc.h @@ -31,6 +31,10 @@ int al_is_sane_alignment_allocator(void) noexcept; } \ void operator delete(void *block) noexcept { al_free(block); } +#define DEF_PLACE_NEWDEL() \ + void *operator new(size_t /*size*/, void *ptr) noexcept { return ptr; } \ + void operator delete(void *block) noexcept { al_free(block); } + namespace al { template<typename T, size_t alignment=DEF_ALIGN> |