From: Wolfgang Bangerth Date: Sun, 1 Mar 2015 16:15:19 +0000 (-0600) Subject: Move assertion whether we are out of memory to the location where we allocate it. X-Git-Tag: v8.3.0-rc1~401^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d1edc300932b500dd4b74edfeb164097bd65754c;p=dealii.git Move assertion whether we are out of memory to the location where we allocate it. --- diff --git a/include/deal.II/lac/vector.h b/include/deal.II/lac/vector.h index 34bd772289..4873249fec 100644 --- a/include/deal.II/lac/vector.h +++ b/include/deal.II/lac/vector.h @@ -1050,9 +1050,8 @@ void Vector::reinit (const size_type n, const bool fast) if (n>max_vec_size) { if (val) deallocate(); - allocate(n); - Assert (val != 0, ExcOutOfMemory()); max_vec_size = n; + allocate(max_vec_size); }; vec_size = n; if (fast == false) diff --git a/include/deal.II/lac/vector.templates.h b/include/deal.II/lac/vector.templates.h index 2beda3f21a..02c4e722f9 100644 --- a/include/deal.II/lac/vector.templates.h +++ b/include/deal.II/lac/vector.templates.h @@ -575,7 +575,6 @@ Vector::Vector (const Vector &v) if (vec_size != 0) { allocate(max_vec_size); - Assert (val != 0, ExcOutOfMemory()); *this = v; } } @@ -595,7 +594,6 @@ Vector::Vector (const Vector &v) if (vec_size != 0) { allocate(max_vec_size); - Assert (val != 0, ExcOutOfMemory()); std::copy (v.begin(), v.end(), begin()); } } @@ -616,7 +614,6 @@ Vector::Vector (const PETScWrappers::Vector &v) if (vec_size != 0) { allocate(max_vec_size); - Assert (val != 0, ExcOutOfMemory()); // get a representation of the vector // and copy it @@ -668,7 +665,6 @@ Vector::Vector (const TrilinosWrappers::MPI::Vector &v) if (vec_size != 0) { allocate(max_vec_size); - Assert (val != 0, ExcOutOfMemory()); // Copy the distributed vector to // a local one at all @@ -702,7 +698,6 @@ Vector::Vector (const TrilinosWrappers::Vector &v) if (vec_size != 0) { allocate(max_vec_size); - Assert (val != 0, ExcOutOfMemory()); // get a representation of the vector // and copy it @@ -2051,6 +2046,7 @@ void Vector::allocate(const size_type size) { val = static_cast(_mm_malloc (sizeof(Number)*size, 64)); + Assert (val != 0, ExcOutOfMemory()); }