]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
liblib: Added pool_alloconly_get_total_used/alloc_size() functions.
authorTimo Sirainen <tss@iki.fi>
Sat, 20 Feb 2010 13:17:16 +0000 (15:17 +0200)
committerTimo Sirainen <tss@iki.fi>
Sat, 20 Feb 2010 13:17:16 +0000 (15:17 +0200)
--HG--
branch : HEAD

src/lib/mempool-alloconly.c
src/lib/mempool.h

index a34f9b73f4daa52998ca38f2105527561d9e02c3..f725fa8697bdd4e7c718984e82ef6fc1eabe7381 100644 (file)
@@ -410,3 +410,29 @@ static size_t pool_alloconly_get_max_easy_alloc_size(pool_t pool)
 
        return apool->block->left;
 }
+
+size_t pool_alloconly_get_total_used_size(pool_t pool)
+{
+       struct alloconly_pool *apool = (struct alloconly_pool *)pool;
+       struct pool_block *block;
+       size_t size = 0;
+
+       i_assert(pool->v == &static_alloconly_pool_vfuncs);
+
+       for (block = apool->block; block != NULL; block = block->prev)
+               size += block->size - block->left;
+       return size;
+}
+
+size_t pool_alloconly_get_total_alloc_size(pool_t pool)
+{
+       struct alloconly_pool *apool = (struct alloconly_pool *)pool;
+       struct pool_block *block;
+       size_t size = 0;
+
+       i_assert(pool->v == &static_alloconly_pool_vfuncs);
+
+       for (block = apool->block; block != NULL; block = block->prev)
+               size += block->size + SIZEOF_POOLBLOCK;
+       return size;
+}
index 0c1663ef6b547be8d7feeb471900eaf7c1e4bb0d..4accac73e992a36e109002dfb32d9ed54e2c0205 100644 (file)
@@ -106,4 +106,11 @@ size_t pool_get_exp_grown_size(pool_t pool, size_t old_size, size_t min_size);
 #define p_get_max_easy_alloc_size(pool) \
        (pool)->v->get_max_easy_alloc_size(pool)
 
+/* These functions are only for pools created with pool_alloconly_create(): */
+
+/* Returns how much memory has been allocated from this pool. */
+size_t pool_alloconly_get_total_used_size(pool_t pool);
+/* Returns how much system memory has been allocated for this pool. */
+size_t pool_alloconly_get_total_alloc_size(pool_t pool);
+
 #endif