]> mj.ucw.cz Git - libucw.git/blobdiff - lib/hashtable.h
Added the local copy of the regex library back.
[libucw.git] / lib / hashtable.h
index c96f0a61c687bd501cbbfe80d2e19ca2795426be..552e88eaa2b183a7bee566c55478a5f4706b407e 100644 (file)
@@ -93,7 +93,6 @@
  *                     deallocation is not supported by mempools, so delete/remove
  *                     will leak pool memory.
  *  HASH_AUTO_POOL=size        Create a pool of the given block size automatically.
- *  HASH_PARAM_POOL    Allocate all nodes from mempool given as a parameter to init().
  *  HASH_ZERO_FILL     New entries should be initialized to all zeroes.
  *  HASH_TABLE_ALLOC   The hash table itself will be allocated and freed using
  *                     the same allocation functions as the nodes instead of
@@ -155,7 +154,7 @@ struct P(table) {
   uns hash_size;
   uns hash_count, hash_max, hash_min, hash_hard_max;
   P(bucket) **ht;
-#if defined(HASH_AUTO_POOL) || defined(HASH_PARAM_POOL)
+#ifdef HASH_AUTO_POOL
   struct mempool *pool;
 #endif
 };
@@ -331,15 +330,6 @@ static inline void P(free) (TAUC void *x UNUSED) { }
 static inline void P(init_alloc) (TAU) { }
 static inline void P(cleanup_alloc) (TAU) { }
 
-#elif defined(HASH_PARAM_POOL)
-/* Use mempools given as a parameter to init() */
-#include "lib/mempool.h"
-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) { }
-static inline void P(cleanup_alloc) (TAU) { }
-#define HASH_USE_POOL
-
 #elif defined(HASH_AUTO_POOL)
 /* Use our own pools */
 #include "lib/mempool.h"
@@ -359,8 +349,8 @@ static inline void P(cleanup_alloc) (TAU) { }
 #endif
 
 #ifdef HASH_TABLE_ALLOC
-static inline void * P(table_alloc) (TAUC unsigned int size) { return P(alloc)(size); }
-static inline void P(table_free) (TAUC void *x) { P(free)(x); }
+static inline void * P(table_alloc) (TAUC unsigned int size) { return P(alloc)(TTC size); }
+static inline void P(table_free) (TAUC void *x) { P(free)(TTC x); }
 #else
 static inline void * P(table_alloc) (TAUC unsigned int size) { return xmalloc(size); }
 static inline void P(table_free) (TAUC void *x) { xfree(x); }
@@ -402,11 +392,7 @@ static void P(alloc_table) (TAU)
     T.hash_min = 0;
 }
 
-#ifndef HASH_PARAM_POOL
 static void P(init) (TA)
-#else
-static void P(init) (TAC struct mempool *pool)
-#endif
 {
   T.hash_count = 0;
   T.hash_size = HASH_DEFAULT_SIZE;
@@ -414,12 +400,9 @@ static void P(init) (TAC struct mempool *pool)
   T.hash_hard_max = 1 << HASH_FN_BITS;
 #else
   T.hash_hard_max = 1 << 28;
-#endif
-  P(alloc_table)(TT);
-#ifdef HASH_PARAM_POOL
-  T.pool = pool;
 #endif
   P(init_alloc)(TT);
+  P(alloc_table)(TT);
 }
 
 #ifdef HASH_WANT_CLEANUP
@@ -628,7 +611,7 @@ do {                                                                                        \
        GLUE_(h_px,node) *h_var = &h_buck->n;
 #define HASH_FOR_ALL(h_px, h_var) HASH_FOR_ALL_DYNAMIC(h_px, &GLUE_(h_px,table), h_var)
 #define HASH_END_FOR } } while(0)
-#define HASH_BREAK 
+#define HASH_BREAK
 #define HASH_CONTINUE continue
 
 #endif
@@ -661,12 +644,13 @@ do {                                                                                      \
 #undef HASH_KEY_DECL
 #undef HASH_KEY_ENDSTRING
 #undef HASH_KEY_STRING
+#undef HASH_KEY_MEMORY
+#undef HASH_KEY_SIZE
 #undef HASH_NOCASE
 #undef HASH_NODE
 #undef HASH_PREFIX
 #undef HASH_USE_POOL
 #undef HASH_AUTO_POOL
-#undef HASH_PARAM_POOL
 #undef HASH_WANT_CLEANUP
 #undef HASH_WANT_DELETE
 #undef HASH_WANT_FIND