]> mj.ucw.cz Git - libucw.git/commitdiff
UCW: implemented shortcut for computing size of a mempool (mp_total_size)
authorPavel Charvat <pavel.charvat@netcentrum.cz>
Tue, 19 Feb 2008 11:15:50 +0000 (12:15 +0100)
committerPavel Charvat <pavel.charvat@netcentrum.cz>
Tue, 19 Feb 2008 11:15:50 +0000 (12:15 +0100)
lib/mempool.c
lib/mempool.h

index 658f53845a99b73605d1fc6a3475318e82793056..fee77f03496d4c6e48d9637f55b3ff255223f208 100644 (file)
@@ -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)
 {
index c53423abc1130a1f8f4600c4535c3e543e4697cd..d8602410fd70b310ca61436672a3d7d3ce88dccb 100644 (file)
@@ -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 ***/