X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fstruct%2Fhashtable.h;h=07a514d5e90330007f558310b946f2af6536b8a4;hb=b7784f18c5317450f776e69dac33c0fd978507ec;hp=695be32772a6b2ff029796237477399aaef1b546;hpb=8a26e7a027c43bc89393a5742aed8d703edff0a0;p=bertos.git diff --git a/bertos/struct/hashtable.h b/bertos/struct/hashtable.h index 695be327..07a514d5 100644 --- a/bertos/struct/hashtable.h +++ b/bertos/struct/hashtable.h @@ -133,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, \ @@ -155,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, \