]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix two issues with C string memory consumption. 983/head
authorDavid Wells <drwells@vt.edu>
Mon, 1 Jun 2015 12:02:49 +0000 (08:02 -0400)
committerDavid Wells <drwells@vt.edu>
Mon, 1 Jun 2015 12:02:49 +0000 (08:02 -0400)
These were pointed out by @msteigemann.

Including cstring to obtain strlen is not necessary with some GCC
releases, but may be needed on other platforms.

I rewrote the call to strlen so that it does not rely on the fact that
sizeof(char) == 1 on most platforms.

include/deal.II/base/memory_consumption.h

index 166d03f32b651610aec0ebf96c1187b374098cbe..c34e8f69a4a176405c9dba08ee6fbd3fc1b8eb62 100644 (file)
@@ -24,6 +24,7 @@
 #include <complex>
 #include <vector>
 #include <cstddef>
+#include <cstring>
 
 DEAL_II_NAMESPACE_OPEN
 
@@ -458,7 +459,7 @@ namespace MemoryConsumption
       }
     else
       {
-        return /*Don't forget about the NUL! :]*/ sizeof(char) + strlen(string);
+        return sizeof(char)*(strlen(string) /*Remember the NUL*/ + 1);
       }
   }
 

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.