aboutsummaryrefslogtreecommitdiff
path: root/src/memusage.h
diff options
context:
space:
mode:
authorglozow <gloriajzhao@gmail.com>2023-09-06 10:49:31 +0100
committerglozow <gloriajzhao@gmail.com>2023-09-13 11:37:45 +0100
commit79ce9f0aa46de8ff742be83fd6f68eab40e073ec (patch)
tree8069a6f4838d59147a16dd82dd1cdc53ccd557ee /src/memusage.h
parent59a35a7398f5bcb3e3805d1e4f363e4c2fb336b3 (diff)
downloadbitcoin-79ce9f0aa46de8ff742be83fd6f68eab40e073ec.tar.xz
add std::list to memusage
Diffstat (limited to 'src/memusage.h')
-rw-r--r--src/memusage.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/memusage.h b/src/memusage.h
index bb39066a7d..08be66172e 100644
--- a/src/memusage.h
+++ b/src/memusage.h
@@ -11,6 +11,7 @@
#include <cassert>
#include <cstdlib>
+#include <list>
#include <map>
#include <memory>
#include <set>
@@ -149,6 +150,21 @@ static inline size_t DynamicUsage(const std::shared_ptr<X>& p)
}
template<typename X>
+struct list_node
+{
+private:
+ void* ptr_next;
+ void* ptr_prev;
+ X x;
+};
+
+template<typename X>
+static inline size_t DynamicUsage(const std::list<X>& l)
+{
+ return MallocUsage(sizeof(list_node<X>)) * l.size();
+}
+
+template<typename X>
struct unordered_node : private X
{
private: