aboutsummaryrefslogtreecommitdiff
path: root/src/memusage.h
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2015-12-01 10:00:04 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2015-12-01 10:22:14 +0100
commit327291af02d05e09188713d882bf68ac708c1077 (patch)
treefd6e45cfb3d11beb185c3d1da556a075c924b165 /src/memusage.h
parent9490bd71bdb41669de7d3c2669241cabf307bb9b (diff)
parent114b5812f6283f2325fc31e186b26c6d76f9551a (diff)
Merge pull request #6914
114b581 Prevector type (Pieter Wuille)
Diffstat (limited to 'src/memusage.h')
-rw-r--r--src/memusage.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/memusage.h b/src/memusage.h
index e96c5bf038..49760e64c7 100644
--- a/src/memusage.h
+++ b/src/memusage.h
@@ -46,7 +46,9 @@ template<typename X> static inline size_t DynamicUsage(const X * const &v) { ret
static inline size_t MallocUsage(size_t alloc)
{
// Measured on libc6 2.19 on Linux.
- if (sizeof(void*) == 8) {
+ if (alloc == 0) {
+ return 0;
+ } else if (sizeof(void*) == 8) {
return ((alloc + 31) >> 4) << 4;
} else if (sizeof(void*) == 4) {
return ((alloc + 15) >> 3) << 3;
@@ -74,6 +76,12 @@ static inline size_t DynamicUsage(const std::vector<X>& v)
return MallocUsage(v.capacity() * sizeof(X));
}
+template<unsigned int N, typename X, typename S, typename D>
+static inline size_t DynamicUsage(const prevector<N, X, S, D>& v)
+{
+ return MallocUsage(v.allocated_memory());
+}
+
template<typename X, typename Y>
static inline size_t DynamicUsage(const std::set<X, Y>& s)
{