From c09b8b755ca6c4e90b65c051673dfa5d808e0f3d Mon Sep 17 00:00:00 2001 From: Pavel Charvat Date: Tue, 19 Feb 2008 12:15:50 +0100 Subject: [PATCH] UCW: implemented shortcut for computing size of a mempool (mp_total_size) --- lib/mempool.c | 8 ++++++++ lib/mempool.h | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/mempool.c b/lib/mempool.c index 658f5384..fee77f03 100644 --- a/lib/mempool.c +++ b/lib/mempool.c @@ -168,6 +168,14 @@ mp_stats(struct mempool *pool, struct mempool_stats *stats) mp_stats_chain(pool->unused, stats, 2); } +u64 +mp_total_size(struct mempool *pool) +{ + struct mempool_stats stats; + mp_stats(pool, &stats); + return stats.total_size; +} + void * mp_alloc_internal(struct mempool *pool, uns size) { diff --git a/lib/mempool.h b/lib/mempool.h index c53423ab..d8602410 100644 --- a/lib/mempool.h +++ b/lib/mempool.h @@ -27,7 +27,7 @@ struct mempool { /* Statistics (see mp_stats()) */ struct mempool_stats { - uns total_size; /* Real allocated size in bytes */ + u64 total_size; /* Real allocated size in bytes */ uns chain_count[3]; /* Number of allocated chunks in small/big/unused chains */ uns chain_size[3]; /* Size of allocated chunks in small/big/unused chains */ }; @@ -46,6 +46,7 @@ void mp_flush(struct mempool *pool); /* Compute some statistics for debug purposes. See the definition of the mempool_stats structure. */ void mp_stats(struct mempool *pool, struct mempool_stats *stats); +u64 mp_total_size(struct mempool *pool); /*** Allocation routines ***/ -- 2.39.2