From 02e5faccef6a54af779ee25cc66cb0e55bc4e42e Mon Sep 17 00:00:00 2001 From: wolf Date: Mon, 2 May 2005 22:29:29 +0000 Subject: [PATCH] Don't allocate memory if the line is empty. git-svn-id: https://svn.dealii.org/trunk@10600 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/source/petsc_matrix_base.cc | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/deal.II/lac/source/petsc_matrix_base.cc b/deal.II/lac/source/petsc_matrix_base.cc index a568ba55eb..7e5f0c9c03 100644 --- a/deal.II/lac/source/petsc_matrix_base.cc +++ b/deal.II/lac/source/petsc_matrix_base.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2004 by the deal.II authors +// Copyright (C) 2004, 2005 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -62,11 +62,20 @@ namespace PETScWrappers ierr = MatGetRow(*matrix, this->a_row, &ncols, &colnums, &values); AssertThrow (ierr == 0, MatrixBase::ExcPETScError(ierr)); - // copy it into our caches - colnum_cache.reset (new std::vector (colnums, - colnums+ncols)); - value_cache.reset (new std::vector (values, values+ncols)); - + // copy it into our caches if the line + // isn't empty + if (ncols != 0) + { + colnum_cache.reset (new std::vector (colnums, + colnums+ncols)); + value_cache.reset (new std::vector (values, values+ncols)); + } + else + { + colnum_cache.reset (); + value_cache.reset (); + } + // and finally restore the matrix ierr = MatRestoreRow(*matrix, this->a_row, &ncols, &colnums, &values); AssertThrow (ierr == 0, MatrixBase::ExcPETScError(ierr)); -- 2.39.5