]> mj.ucw.cz Git - libucw.git/commitdiff
Let eltpools maintain the number of allocated items. The overhead
authorMartin Mares <mj@ucw.cz>
Mon, 10 Sep 2007 18:03:27 +0000 (20:03 +0200)
committerMartin Mares <mj@ucw.cz>
Mon, 10 Sep 2007 18:03:27 +0000 (20:03 +0200)
is minimal and it helps debugging.

lib/eltpool.h

index a682405cf1726c4bcea9d6ec278bc7c42f4c6de7..7e295fb7b0d4bbaa71acb90f42fc4b386a4993cc 100644 (file)
@@ -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);