From 493017924f02d69dcc554af0671c514f7a39c2f8 Mon Sep 17 00:00:00 2001 From: Pavel Charvat Date: Fri, 29 Feb 2008 19:05:51 +0100 Subject: [PATCH] UCW: implemented ep_total_size (similar to mp_total_size) --- lib/eltpool.c | 7 +++++++ lib/eltpool.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/lib/eltpool.c b/lib/eltpool.c index f82de845..b32843fc 100644 --- a/lib/eltpool.c +++ b/lib/eltpool.c @@ -60,9 +60,16 @@ ep_alloc_slow(struct eltpool *pool) } ch->next = pool->first_chunk; pool->first_chunk = ch; + pool->num_chunks++; return p; } +u64 +ep_total_size(struct eltpool *pool) +{ + return (u64)pool->num_chunks * pool->chunk_size + sizeof(*pool); +} + #ifdef TEST #include diff --git a/lib/eltpool.h b/lib/eltpool.h index 7e295fb7..795a45e9 100644 --- a/lib/eltpool.h +++ b/lib/eltpool.h @@ -17,6 +17,7 @@ struct eltpool { uns chunk_size; uns elts_per_chunk; uns num_allocated; // Just for debugging + uns num_chunks; }; struct eltpool_chunk { @@ -31,6 +32,7 @@ struct eltpool_free { struct eltpool *ep_new(uns elt_size, uns elts_per_chunk); void ep_delete(struct eltpool *pool); void *ep_alloc_slow(struct eltpool *pool); +u64 ep_total_size(struct eltpool *pool); static inline void * ep_alloc(struct eltpool *pool) -- 2.39.2