From: bangerth Date: Thu, 6 Nov 2008 03:20:07 +0000 (+0000) Subject: Use clear() to release memory, rather than doing it by hand in each of the derived... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=006801f3913e135f09bb4ba9a733188f79f1eb5c;p=dealii-svn.git Use clear() to release memory, rather than doing it by hand in each of the derived classes. git-svn-id: https://svn.dealii.org/trunk@17482 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/block_sparse_matrix.templates.h b/deal.II/lac/include/lac/block_sparse_matrix.templates.h index 9c0e277add..a22eeec2c0 100644 --- a/deal.II/lac/include/lac/block_sparse_matrix.templates.h +++ b/deal.II/lac/include/lac/block_sparse_matrix.templates.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -45,14 +45,7 @@ BlockSparseMatrix::~BlockSparseMatrix () { // delete previous content of // the subobjects array - for (unsigned int r=0; rn_block_rows(); ++r) - for (unsigned int c=0; cn_block_cols(); ++c) - { - BlockType *p = this->sub_objects[r][c]; - this->sub_objects[r][c] = 0; - delete p; - } - + clear (); sparsity_pattern = 0; } @@ -114,14 +107,7 @@ reinit (const BlockSparsityPattern &sparsity) // first delete previous content of // the subobjects array and delete // the table completely - for (unsigned int r=0; rn_block_rows(); ++r) - for (unsigned int c=0; cn_block_cols(); ++c) - { - BlockType *p = this->sub_objects[r][c]; - this->sub_objects[r][c] = 0; - delete p; - } - this->sub_objects.reinit (0,0); + clear (); // then associate new sparsity // pattern and resize diff --git a/deal.II/lac/include/lac/block_sparse_matrix_ez.templates.h b/deal.II/lac/include/lac/block_sparse_matrix_ez.templates.h index 79cfcc043d..56eb25c325 100644 --- a/deal.II/lac/include/lac/block_sparse_matrix_ez.templates.h +++ b/deal.II/lac/include/lac/block_sparse_matrix_ez.templates.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2002, 2003, 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2008 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -46,13 +46,7 @@ BlockSparseMatrixEZ (const unsigned int rows, // { // // delete previous content of // // the subobjects array -// for (unsigned int r=0; r *p = sub_objects[r][c]; -// sub_objects[r][c] = 0; -// delete p; -// }; +// clear (); // }; diff --git a/deal.II/lac/source/petsc_block_sparse_matrix.cc b/deal.II/lac/source/petsc_block_sparse_matrix.cc index a4c3a8fc4d..4759d172e4 100644 --- a/deal.II/lac/source/petsc_block_sparse_matrix.cc +++ b/deal.II/lac/source/petsc_block_sparse_matrix.cc @@ -58,15 +58,7 @@ namespace PETScWrappers { // first delete previous content of // the subobjects array - for (unsigned int r=0; rn_block_rows(); ++r) - for (unsigned int c=0; cn_block_cols(); ++c) - { - BlockType *p = this->sub_objects[r][c]; - this->sub_objects[r][c] = 0; - delete p; - } - - this->sub_objects.reinit (0,0); + clear (); // then resize. set sizes of blocks to // zero. user will later have to call diff --git a/deal.II/lac/source/petsc_parallel_block_sparse_matrix.cc b/deal.II/lac/source/petsc_parallel_block_sparse_matrix.cc index ec7cb38eae..ca98f33066 100644 --- a/deal.II/lac/source/petsc_parallel_block_sparse_matrix.cc +++ b/deal.II/lac/source/petsc_parallel_block_sparse_matrix.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 2004, 2005, 2006, 2008 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -61,15 +61,7 @@ namespace PETScWrappers { // first delete previous content of // the subobjects array - for (unsigned int r=0; rn_block_rows(); ++r) - for (unsigned int c=0; cn_block_cols(); ++c) - { - BlockType *p = this->sub_objects[r][c]; - this->sub_objects[r][c] = 0; - delete p; - } - - this->sub_objects.reinit (0,0); + clear (); // then resize. set sizes of blocks to // zero. user will later have to call diff --git a/deal.II/lac/source/trilinos_block_sparse_matrix.cc b/deal.II/lac/source/trilinos_block_sparse_matrix.cc index 4fbee6fd4f..8fc6101880 100644 --- a/deal.II/lac/source/trilinos_block_sparse_matrix.cc +++ b/deal.II/lac/source/trilinos_block_sparse_matrix.cc @@ -30,13 +30,7 @@ namespace TrilinosWrappers { // delete previous content of // the subobjects array - for (unsigned int r=0; rn_block_rows(); ++r) - for (unsigned int c=0; cn_block_cols(); ++c) - { - BlockType *p = this->sub_objects[r][c]; - this->sub_objects[r][c] = 0; - delete p; - } + clear (); } @@ -70,15 +64,7 @@ namespace TrilinosWrappers { // first delete previous content of // the subobjects array - for (unsigned int r=0; rn_block_rows(); ++r) - for (unsigned int c=0; cn_block_cols(); ++c) - { - BlockType *p = this->sub_objects[r][c]; - this->sub_objects[r][c] = 0; - delete p; - } - - this->sub_objects.reinit (0,0); + clear (); // then resize. set sizes of blocks to // zero. user will later have to call