diff options
author | 2020-06-29 17:02:13 -0700 | |
---|---|---|
committer | 2020-06-29 17:03:57 -0700 | |
commit | afb3a9b6cbbaaf187fb57b5eb193ba99b60418e1 (patch) | |
tree | 26c6c04d9a3b680990cfce72e8adf4b252b6e147 | |
parent | f43c648f5d354789575ab2fd15684532b11a6483 (diff) |
Fix crash on Windows when freeing netlist objects.
-rw-r--r-- | src/lib/netlist/plib/palloc.h | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/lib/netlist/plib/palloc.h b/src/lib/netlist/plib/palloc.h index a2f4527adb1..e1ad17637fe 100644 --- a/src/lib/netlist/plib/palloc.h +++ b/src/lib/netlist/plib/palloc.h @@ -241,10 +241,12 @@ namespace plib { public: using value_type = T; using pointer = T *; - static /*constexpr*/ const std::size_t align_size = ALIGN; + static /*constexpr*/ const std::size_t align_size = (ALIGN < 16) ? 16 : ALIGN; using arena_type = ARENA; - static_assert(align_size >= alignof(T) && (align_size % alignof(T)) == 0, + static_assert(align_size >= alignof(T), + "ALIGN must be greater than alignof(T) and a multiple"); + static_assert((align_size % alignof(T)) == 0, "ALIGN must be greater than alignof(T) and a multiple"); arena_allocator() noexcept @@ -436,8 +438,12 @@ namespace plib { //unused_var(size); dec_alloc_stat(size); #if (PUSE_ALIGNED_ALLOCATION) - // NOLINTNEXTLINE(cppcoreguidelines-no-malloc) + #if defined(_WIN32) || defined(_WIN64) || defined(_MSC_VER) + _aligned_free(ptr); + #else + // NOLINTNEXTLINE(cppcoreguidelines-no-malloc) ::free(ptr); + #endif #else ::operator delete(ptr); #endif |