From: Martin Mares Date: Mon, 10 Sep 2007 18:03:27 +0000 (+0200) Subject: Let eltpools maintain the number of allocated items. The overhead X-Git-Tag: holmes-import~506^2~13^2~24 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=9adbef3afa83fb9d9edf7054c98b0821f89cd831;p=libucw.git Let eltpools maintain the number of allocated items. The overhead is minimal and it helps debugging. --- 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);