Commit 54eefb54 by Maarten L. Hekkelman

Fix memory leak

parent 84dd2187
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.16)
# set the project name # set the project name
project(cifpp VERSION 5.0.8 LANGUAGES CXX) project(cifpp VERSION 5.0.9 LANGUAGES CXX)
list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
......
...@@ -4,6 +4,7 @@ Version 5.0.8 ...@@ -4,6 +4,7 @@ Version 5.0.8
- Change in writing out PDB files, now looking up the original auth_seq_num - Change in writing out PDB files, now looking up the original auth_seq_num
via the pdbx_xxx_scheme categories based on the atom_site.auth_seq_num -> via the pdbx_xxx_scheme categories based on the atom_site.auth_seq_num ->
pdbx_xxx_scheme.pdb_seq_num relationship. pdbx_xxx_scheme.pdb_seq_num relationship.
- fix memory leak in category
Version 5.0.7.1 Version 5.0.7.1
- Use the implementation from zeep for std::experimental::is_detected - Use the implementation from zeep for std::experimental::is_detected
......
...@@ -600,7 +600,7 @@ category::category(const category &rhs) ...@@ -600,7 +600,7 @@ category::category(const category &rhs)
for (auto r = rhs.m_head; r != nullptr; r = r->m_next) for (auto r = rhs.m_head; r != nullptr; r = r->m_next)
insert_impl(end(), clone_row(*r)); insert_impl(end(), clone_row(*r));
if (m_cat_validator != nullptr) if (m_cat_validator != nullptr and m_index == nullptr)
m_index = new category_index(this); m_index = new category_index(this);
} }
...@@ -644,7 +644,7 @@ category &category::operator=(const category &rhs) ...@@ -644,7 +644,7 @@ category &category::operator=(const category &rhs)
m_validator = rhs.m_validator; m_validator = rhs.m_validator;
m_cat_validator = rhs.m_cat_validator; m_cat_validator = rhs.m_cat_validator;
if (m_cat_validator != nullptr) if (m_cat_validator != nullptr and m_index == nullptr)
m_index = new category_index(this); m_index = new category_index(this);
} }
...@@ -655,9 +655,6 @@ category &category::operator=(category &&rhs) ...@@ -655,9 +655,6 @@ category &category::operator=(category &&rhs)
{ {
if (this != &rhs) if (this != &rhs)
{ {
if (not empty())
clear();
m_name = std::move(rhs.m_name); m_name = std::move(rhs.m_name);
m_columns = std::move(rhs.m_columns); m_columns = std::move(rhs.m_columns);
m_cascade = rhs.m_cascade; m_cascade = rhs.m_cascade;
...@@ -665,12 +662,10 @@ category &category::operator=(category &&rhs) ...@@ -665,12 +662,10 @@ category &category::operator=(category &&rhs)
m_cat_validator = rhs.m_cat_validator; m_cat_validator = rhs.m_cat_validator;
m_parent_links = rhs.m_parent_links; m_parent_links = rhs.m_parent_links;
m_child_links = rhs.m_child_links; m_child_links = rhs.m_child_links;
m_index = rhs.m_index;
m_head = rhs.m_head;
m_tail = rhs.m_tail;
rhs.m_head = rhs.m_tail = nullptr; std::swap(m_index, rhs.m_index);
rhs.m_index = nullptr; std::swap(m_head, rhs.m_head);
std::swap(m_tail, rhs.m_tail);
} }
return *this; return *this;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment