Skip to content

Commit

Permalink
Setup Bits_Data to only delete memory if it exists.
Browse files Browse the repository at this point in the history
  • Loading branch information
mercere99 committed Dec 1, 2023
1 parent bd0d54a commit fe0194d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions include/emp/bits/Bits_Data.hpp
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -231,9 +231,9 @@ namespace emp {
{
if (num_bits) bits = NewArrayPtr<field_t>(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; }
Expand Down

0 comments on commit fe0194d

Please sign in to comment.