From fe0194d70271b467296a01b67aaa00b774001865 Mon Sep 17 00:00:00 2001 From: Charles Ofria Date: Fri, 1 Dec 2023 15:14:37 -0500 Subject: [PATCH] Setup Bits_Data to only delete memory if it exists. --- include/emp/bits/Bits_Data.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/emp/bits/Bits_Data.hpp b/include/emp/bits/Bits_Data.hpp index e8fe4a0a03..ddb106ae25 100644 --- a/include/emp/bits/Bits_Data.hpp +++ b/include/emp/bits/Bits_Data.hpp @@ -1,7 +1,7 @@ /** * @note This file is part of Empirical, https://github.com/devosoft/Empirical * @copyright Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md - * @date 2022. + * @date 2022-23. * * @file Bits_Data.hpp * @brief Helper class to handle memory management for Bits objects. @@ -231,9 +231,9 @@ namespace emp { { if (num_bits) bits = NewArrayPtr(NumBitFields(num_bits)); } - Bits_Data_Mem_Dynamic(const Bits_Data_Mem_Dynamic & in) : bits(nullptr) { Copy(in); } + Bits_Data_Mem_Dynamic(const Bits_Data_Mem_Dynamic & in) : base_t(), bits(nullptr) { Copy(in); } Bits_Data_Mem_Dynamic(Bits_Data_Mem_Dynamic && in) : bits(nullptr) { Move(std::move(in)); } - ~Bits_Data_Mem_Dynamic() { bits.DeleteArray(); } + ~Bits_Data_Mem_Dynamic() { if (bits) bits.DeleteArray(); } Bits_Data_Mem_Dynamic & operator=(const Bits_Data_Mem_Dynamic & in) { Copy(in); return *this; } Bits_Data_Mem_Dynamic & operator=(Bits_Data_Mem_Dynamic && in) { Move(std::move(in)); return *this; }