From 61298d392550dd61e65a84f7e1f683a5987614b4 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 8 Nov 2013 13:55:40 +0100 Subject: [PATCH 1/4] Fix memory leak in Compact_container::merge() We forgot to merge all_items --- STL_Extension/include/CGAL/Compact_container.h | 1 + 1 file changed, 1 insertion(+) diff --git a/STL_Extension/include/CGAL/Compact_container.h b/STL_Extension/include/CGAL/Compact_container.h index 23d5b939013..766576ff23b 100644 --- a/STL_Extension/include/CGAL/Compact_container.h +++ b/STL_Extension/include/CGAL/Compact_container.h @@ -612,6 +612,7 @@ void Compact_container::merge(Self &d) set_type(d.first_item, last_item, BLOCK_BOUNDARY); last_item = d.last_item; } + all_items.insert(all_items.end(), d.all_items.begin(), d.all_items.end()); // Add the sizes. size_ += d.size_; // Add the capacities. From 06009bfc03ab2d65f68994e48d10ab30281379d0 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Sun, 10 Nov 2013 20:09:08 +0100 Subject: [PATCH 2/4] fix leaks --- .../test/STL_Extension/test_In_place_list.cpp | 6 +++++- .../test/STL_Extension/test_stl_extension.cpp | 13 ++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/STL_Extension/test/STL_Extension/test_In_place_list.cpp b/STL_Extension/test/STL_Extension/test_In_place_list.cpp index 60488c18497..5a31a88d0ae 100644 --- a/STL_Extension/test/STL_Extension/test_In_place_list.cpp +++ b/STL_Extension/test/STL_Extension/test_In_place_list.cpp @@ -884,10 +884,11 @@ void test_In_place_list() { assert( l.size() == 5); assert( std::equal( l.begin(), l.end(), b)); } + { typedef CGAL::In_place_list ContList; typedef CGAL::In_place_list::iterator Iterator; - + ContList L; L.push_back(* new Cont(3)); L.push_back(* new Cont(5)); @@ -900,7 +901,10 @@ void test_In_place_list() { for (++it2; it2 != L.end(); it1=it2, ++it2) { assert( (*it1).i_ <= (*it2).i_ ); } + + L.destroy(); } + } int main() { diff --git a/STL_Extension/test/STL_Extension/test_stl_extension.cpp b/STL_Extension/test/STL_Extension/test_stl_extension.cpp index c2ecc068ab5..d106dbca477 100644 --- a/STL_Extension/test/STL_Extension/test_stl_extension.cpp +++ b/STL_Extension/test/STL_Extension/test_stl_extension.cpp @@ -1663,7 +1663,7 @@ void test_Iterator_project() l.destroy(); l2.destroy(); } - + // // //============================================ @@ -1990,7 +1990,7 @@ void test_Iterator_project() l.destroy(); l2.destroy(); } - + // // //============================================ @@ -2888,8 +2888,14 @@ void test_Iterator_project() } CGAL::Assert_iterator( c_begin); CGAL::Assert_iterator( c_end); + + while(! l.empty()){ + delete l.back(); + l.pop_back(); } - + + } + // // //============================================ @@ -5172,6 +5178,7 @@ void test_Circulator_on_node() { delete start; start = p; } + delete end; } } void test_N_step_adaptor() { From d8da1137ccf5666eb3bb4048b929a1f578a85b7d Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 14 Nov 2013 10:40:49 +0100 Subject: [PATCH 3/4] Fix a memory leak in Handle_with_policy: A rep that points to another rep is like a handle So if such a rep gets deleted the reference counter must be decremented --- STL_Extension/include/CGAL/Handle_with_policy.h | 1 + 1 file changed, 1 insertion(+) diff --git a/STL_Extension/include/CGAL/Handle_with_policy.h b/STL_Extension/include/CGAL/Handle_with_policy.h index df463d2d321..905a5435758 100644 --- a/STL_Extension/include/CGAL/Handle_with_policy.h +++ b/STL_Extension/include/CGAL/Handle_with_policy.h @@ -555,6 +555,7 @@ public: } } else { h.delete_rep( rep); // we have to delete the current rep + tmp->remove_reference(); } rep = tmp; } From 11c186e76916b4aa6641ae4d96f78402c8001aa3 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 10 Dec 2013 18:56:42 +0100 Subject: [PATCH 4/4] Fix a warning --- STL_Extension/test/STL_Extension/test_stl_extension.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/STL_Extension/test/STL_Extension/test_stl_extension.cpp b/STL_Extension/test/STL_Extension/test_stl_extension.cpp index d106dbca477..9f5a096b414 100644 --- a/STL_Extension/test/STL_Extension/test_stl_extension.cpp +++ b/STL_Extension/test/STL_Extension/test_stl_extension.cpp @@ -2890,7 +2890,7 @@ void test_Iterator_project() CGAL::Assert_iterator( c_end); while(! l.empty()){ - delete l.back(); + delete static_cast(l.back()); l.pop_back(); }