From d5ce623f0be14a35b1adf42bdcd5773da925760e Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Fri, 20 Oct 2017 10:52:44 -0600 Subject: [PATCH] Make sure we call 'free()' instead of 'delete[]'. --- include/deal.II/lac/la_parallel_vector.h | 6 +++++- include/deal.II/lac/la_parallel_vector.templates.h | 12 ++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/deal.II/lac/la_parallel_vector.h b/include/deal.II/lac/la_parallel_vector.h index 7988201261..08721841e1 100644 --- a/include/deal.II/lac/la_parallel_vector.h +++ b/include/deal.II/lac/la_parallel_vector.h @@ -1082,8 +1082,12 @@ namespace LinearAlgebra /** * Pointer to the array of local elements of this vector. + * + * Because we allocate these arrays via Utilities::System::posix_memalign, + * we need to use a custom deleter for this object that does not call + * delete[], but instead calls @p free(). */ - std::unique_ptr values; + std::unique_ptr values; /** * For parallel loops with TBB, this member variable stores the affinity diff --git a/include/deal.II/lac/la_parallel_vector.templates.h b/include/deal.II/lac/la_parallel_vector.templates.h index 5edb5c8db1..c120889a0e 100644 --- a/include/deal.II/lac/la_parallel_vector.templates.h +++ b/include/deal.II/lac/la_parallel_vector.templates.h @@ -204,7 +204,7 @@ namespace LinearAlgebra : partitioner (new Utilities::MPI::Partitioner()), allocated_size (0), - values (nullptr) + values (nullptr, &free) { reinit(0); } @@ -216,7 +216,7 @@ namespace LinearAlgebra : Subscriptor(), allocated_size (0), - values (nullptr), + values (nullptr, &free), vector_is_ghosted (false) { reinit (v, true); @@ -240,7 +240,7 @@ namespace LinearAlgebra const MPI_Comm communicator) : allocated_size (0), - values (nullptr), + values (nullptr, &free), vector_is_ghosted (false) { reinit (local_range, ghost_indices, communicator); @@ -253,7 +253,7 @@ namespace LinearAlgebra const MPI_Comm communicator) : allocated_size (0), - values (nullptr), + values (nullptr, &free), vector_is_ghosted (false) { reinit (local_range, communicator); @@ -265,7 +265,7 @@ namespace LinearAlgebra Vector::Vector (const size_type size) : allocated_size (0), - values (nullptr), + values (nullptr, &free), vector_is_ghosted (false) { reinit (size, false); @@ -278,7 +278,7 @@ namespace LinearAlgebra Vector (const std::shared_ptr &partitioner) : allocated_size (0), - values (nullptr), + values (nullptr, &free), vector_is_ghosted (false) { reinit (partitioner); -- 2.39.5