Skip to content

Commit

Permalink
add std::list to memusage
Browse files Browse the repository at this point in the history
  • Loading branch information
glozow committed Sep 13, 2023
1 parent 59a35a7 commit 79ce9f0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/memusage.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <cassert>
#include <cstdlib>
#include <list>
#include <map>
#include <memory>
#include <set>
Expand Down Expand Up @@ -148,6 +149,21 @@ static inline size_t DynamicUsage(const std::shared_ptr<X>& p)
return p ? MallocUsage(sizeof(X)) + MallocUsage(sizeof(stl_shared_counter)) : 0;
}

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
{
Expand Down

0 comments on commit 79ce9f0

Please sign in to comment.