diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-03-20 12:46:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-20 12:46:28 +0100 |
commit | 7f9d83b4552783d6ba6ee16d7742fe3961c8319a (patch) | |
tree | 60f47357d5d6d8e443cbf6724b60cf434472933f | |
parent | 605fde0ceb8a8d1732efc18e61c3a0e8b657037b (diff) | |
parent | a957c648ab6d1ba61ee81da7aa466b05c795b808 (diff) |
Merge pull request #26496 from vespa-engine/balder/verify-magic
Verify magic at destruction.
-rw-r--r-- | vespamalloc/src/vespamalloc/malloc/overload.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/vespamalloc/src/vespamalloc/malloc/overload.h b/vespamalloc/src/vespamalloc/malloc/overload.h index abfe376b38b..725ca761ec1 100644 --- a/vespamalloc/src/vespamalloc/malloc/overload.h +++ b/vespamalloc/src/vespamalloc/malloc/overload.h @@ -11,11 +11,17 @@ class CreateAllocator { public: - CreateAllocator() : _initialized(0x192A3B4C) { + static constexpr unsigned CONSTRUCTED = 0x192A3B4C; + static constexpr unsigned DESTRUCTED = 0xd1d2d3d4; + CreateAllocator() : _initialized(CONSTRUCTED) { vespamalloc::createAllocator(); } + ~CreateAllocator() { + assert(_initialized == CONSTRUCTED); + _initialized = DESTRUCTED; + } private: - [[maybe_unused]] unsigned _initialized; + unsigned _initialized; }; static CreateAllocator _CreateAllocator __attribute__ ((init_priority (543))); |