X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fstruct%2Fhashtable.h;h=07a514d5e90330007f558310b946f2af6536b8a4;hb=580aa21ef4c17152eea413db8d6e0e09a4fbbf44;hp=0b6f4c8f23816fa9b5f42ba6a676c5cde68b94d6;hpb=4b025f27d2a79fb44ee515f89bbf0123321fd81f;p=bertos.git diff --git a/bertos/struct/hashtable.h b/bertos/struct/hashtable.h index 0b6f4c8f..07a514d5 100644 --- a/bertos/struct/hashtable.h +++ b/bertos/struct/hashtable.h @@ -30,7 +30,9 @@ * Copyright 2004 Giovanni Bajo * --> * - * \author Giovanni Bajo + * \defgroup hashtable Hash table implementation + * \ingroup struct + * \{ * * \brief Portable hash table * @@ -50,6 +52,8 @@ * a marker for a free node, so it is invalid to store a NULL pointer in the table * with \c ht_insert(). * + * \author Giovanni Bajo + * * $WIZ$ module_name = "hashtable" * $WIZ$ module_configuration = "bertos/cfg/cfg_hashtable.h" */ @@ -129,7 +133,8 @@ typedef struct /** Exactly like \c DECLARE_HASHTABLE, but the variable will be declared as static. */ #define DECLARE_HASHTABLE_STATIC(name, size, hook_gk) \ - static const void* name##_nodes[1 << UINT32_LOG2(size)]; \ + enum { name##_SIZE = (1 << UINT32_LOG2(size)), }; \ + static const void* name##_nodes[name##_SIZE]; \ static struct HashTable name = \ { \ .mem = name##_nodes, \ @@ -151,8 +156,10 @@ typedef struct /** Exactly like \c DECLARE_HASHTABLE_INTERNALKEY, but the variable will be declared as static. */ #define DECLARE_HASHTABLE_INTERNALKEY_STATIC(name, size) \ - static uint8_t name##_keys[(1 << UINT32_LOG2(size)) * (INTERNAL_KEY_MAX_LENGTH + 1)]; \ - static const void* name##_nodes[1 << UINT32_LOG2(size)]; \ + enum { name##_KEYS = ((1 << UINT32_LOG2(size)) * (INTERNAL_KEY_MAX_LENGTH + 1)), \ + name##_SIZE = (1 << UINT32_LOG2(size)), }; \ + static uint8_t name##_keys[name##_KEYS]; \ + static const void* name##_nodes[name##_SIZE]; \ static struct HashTable name = \ { \ .mem = name##_nodes, \ @@ -289,4 +296,6 @@ int hashtable_testSetup(void); int hashtable_testRun(void); int hashtable_testTearDown(void); +/** \} */ // \defgroup hashtable + #endif /* STRUCT_HASHTABLE_H */