diff options
author | Chris Robinson <[email protected]> | 2020-03-22 13:28:45 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-03-22 13:28:45 -0700 |
commit | 49b2d703e771a9d5a4cebf13ab017f7c06251c9b (patch) | |
tree | 873854d7bdf57248fcfea39cb1fc7a7e72e26c64 /common | |
parent | 3c631149e35e5f8c7ab88a28da05b0f7882420b1 (diff) |
Properly define the new[] and delete[] operators
Diffstat (limited to 'common')
-rw-r--r-- | common/almalloc.h | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/common/almalloc.h b/common/almalloc.h index 804ea9d8..d56c8543 100644 --- a/common/almalloc.h +++ b/common/almalloc.h @@ -25,12 +25,17 @@ void al_free(void *ptr) noexcept; if(!ret) throw std::bad_alloc(); \ return ret; \ } \ - void operator delete(void *block) noexcept { al_free(block); } + void *operator new[](size_t size) { return operator new(size); } \ + void operator delete(void *block) noexcept { al_free(block); } \ + void operator delete[](void *block) noexcept { operator delete(block); } #define DEF_PLACE_NEWDEL() \ void *operator new(size_t /*size*/, void *ptr) noexcept { return ptr; } \ + void *operator new[](size_t /*size*/, void *ptr) noexcept { return ptr; } \ void operator delete(void *block, void*) noexcept { al_free(block); } \ - void operator delete(void *block) noexcept { al_free(block); } + void operator delete(void *block) noexcept { al_free(block); } \ + void operator delete[](void *block, void*) noexcept { al_free(block); } \ + void operator delete[](void *block) noexcept { al_free(block); } struct FamCount { size_t mCount; }; @@ -44,8 +49,10 @@ struct FamCount { size_t mCount; }; return ret; \ throw std::bad_alloc(); \ } \ + void *operator new[](size_t /*size*/) = delete; \ void operator delete(void *block, FamCount) { al_free(block); } \ - void operator delete(void *block) noexcept { al_free(block); } + void operator delete(void *block) noexcept { al_free(block); } \ + void operator delete[](void* /*block*/) = delete; namespace al { |