From: Martin Mares Date: Mon, 4 Jul 2005 07:37:47 +0000 (+0000) Subject: Fixed a nasty bug in hash table allocation. HASH_AUTO_POOL must use X-Git-Tag: holmes-import~759 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=f17e1caeeb9f234aa131b98659d16475f9d198bd;p=libucw.git Fixed a nasty bug in hash table allocation. HASH_AUTO_POOL must use a pool local to the hash table, otherwise it collides with HASH_DYNAMIC. --- diff --git a/lib/hashtable.h b/lib/hashtable.h index 65931b67..486fe30b 100644 --- a/lib/hashtable.h +++ b/lib/hashtable.h @@ -151,6 +151,9 @@ struct P(table) { uns hash_size; uns hash_count, hash_max, hash_min, hash_hard_max; P(bucket) **ht; +#ifdef HASH_AUTO_POOL + struct mempool *pool; +#endif }; #ifdef HASH_TABLE_DYNAMIC @@ -305,11 +308,11 @@ static inline void P(cleanup_alloc) (TAU) { } #elif defined(HASH_AUTO_POOL) /* Use our own pools */ #include "lib/mempool.h" -static struct mempool *P(pool); -static inline void * P(alloc) (TAUC unsigned int size) { return mp_alloc_fast(P(pool), size); } +static inline void * P(alloc) (TAUC unsigned int size) { return mp_alloc_fast(T.pool, size); } static inline void P(free) (TAUC void *x UNUSED) { } -static inline void P(init_alloc) (TAU) { P(pool) = mp_new(HASH_AUTO_POOL); } -static inline void P(cleanup_alloc) (TAU) { mp_delete(P(pool)); } +static inline void P(init_alloc) (TAU) { T.pool = mp_new(HASH_AUTO_POOL); } +static inline void P(cleanup_alloc) (TAU) { mp_delete(T.pool); } +#define HASH_USE_POOL #else /* The default allocation method */