From 9adbef3afa83fb9d9edf7054c98b0821f89cd831 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Mon, 10 Sep 2007 20:03:27 +0200 Subject: [PATCH] Let eltpools maintain the number of allocated items. The overhead is minimal and it helps debugging. --- lib/eltpool.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/eltpool.h b/lib/eltpool.h index a682405c..7e295fb7 100644 --- a/lib/eltpool.h +++ b/lib/eltpool.h @@ -16,6 +16,7 @@ struct eltpool { uns elt_size; uns chunk_size; uns elts_per_chunk; + uns num_allocated; // Just for debugging }; struct eltpool_chunk { @@ -34,6 +35,7 @@ void *ep_alloc_slow(struct eltpool *pool); static inline void * ep_alloc(struct eltpool *pool) { + pool->num_allocated++; #ifdef CONFIG_FAKE_ELTPOOL return xmalloc(pool->elt_size); #else @@ -49,6 +51,7 @@ ep_alloc(struct eltpool *pool) static inline void ep_free(struct eltpool *pool, void *p) { + pool->num_allocated--; #ifdef CONFIG_FAKE_ELTPOOL (void) pool; xfree(p); -- 2.39.5