]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Ensure we don't create a memory leak.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Sun, 1 Mar 2015 16:20:47 +0000 (10:20 -0600)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Sun, 1 Mar 2015 19:08:07 +0000 (13:08 -0600)
include/deal.II/lac/vector.templates.h

index 40e416589a45f33d5e66a6eb8b45630f7fa19473..9aa6f0d26160cc36e9dd6c9bdd69f20b72426f7a 100644 (file)
@@ -2045,6 +2045,8 @@ template <typename Number>
 void
 Vector<Number>::allocate()
 {
+  // make sure that we don't create a memory leak
+  Assert (val == 0, ExcInternalError());
   val = static_cast<Number *>(_mm_malloc (sizeof(Number)*max_vec_size, 64));
   Assert (val != 0, ExcOutOfMemory());
 }
@@ -2056,6 +2058,7 @@ void
 Vector<Number>::deallocate()
 {
   _mm_free(val);
+  val = 0;
 }
 
 DEAL_II_NAMESPACE_CLOSE

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.