[libdazzle] trie: use G_STATIC_ASSERT()



commit 7e6f2519ef4c9a6c3c60729046cc02e1900caf87
Author: Christian Hergert <chergert redhat com>
Date:   Tue Sep 12 15:33:41 2017 -0700

    trie: use G_STATIC_ASSERT()
    
    These old STATIC_ASSERT() come from the days when we were not using glib.
    Not necessary to keep that around anymore.

 src/search/dzl-trie.c |   37 ++++++++++++++-----------------------
 1 files changed, 14 insertions(+), 23 deletions(-)
---
diff --git a/src/search/dzl-trie.c b/src/search/dzl-trie.c
index 64fcd8e..ee1b928 100644
--- a/src/search/dzl-trie.c
+++ b/src/search/dzl-trie.c
@@ -27,11 +27,6 @@
 # define TRIE_64 1
 #endif
 
-#define STATIC_ASSERT(a)                              \
-   G_STMT_START {                                     \
-      G_GNUC_UNUSED gchar static_assert[(a)? 0 : -1]; \
-   } G_STMT_END
-
 /**
  * SECTION:trie
  * @title: DzlTrie
@@ -117,6 +112,20 @@ struct _DzlTrie
    DzlTrieNode    *root;
 };
 
+#ifdef TRIE_64
+  G_STATIC_ASSERT (sizeof(gpointer) == 8);
+  G_STATIC_ASSERT ((FIRST_CHUNK_KEYS-1) == 3);
+  G_STATIC_ASSERT (((FIRST_CHUNK_KEYS-1) * sizeof(gpointer)) == 24);
+  G_STATIC_ASSERT(sizeof(DzlTrieNode) == 32);
+  G_STATIC_ASSERT(sizeof(DzlTrieNodeChunk) == 16);
+#else
+  G_STATIC_ASSERT (sizeof(gpointer) == 4);
+  G_STATIC_ASSERT ((FIRST_CHUNK_KEYS-1) == 2);
+  G_STATIC_ASSERT (((FIRST_CHUNK_KEYS-1) * sizeof(gpointer)) == 8);
+  G_STATIC_ASSERT(sizeof(DzlTrieNode) == 20);
+  G_STATIC_ASSERT(sizeof(DzlTrieNodeChunk) == 12);
+#endif
+
 /**
  * dzl_trie_malloc0:
  * @trie: A #DzlTrie
@@ -266,16 +275,6 @@ dzl_trie_node_move_to_front (DzlTrieNode      *node,
    chunk->keys[idx] = first->keys[offset];
    chunk->children[idx] = first->children[offset];
 
-#ifdef TRIE_64
-   STATIC_ASSERT(sizeof(gpointer) == 8);
-   STATIC_ASSERT((FIRST_CHUNK_KEYS-1) == 3);
-   STATIC_ASSERT(((FIRST_CHUNK_KEYS-1) * sizeof(gpointer)) == 24);
-#else
-   STATIC_ASSERT(sizeof(gpointer) == 4);
-   STATIC_ASSERT((FIRST_CHUNK_KEYS-1) == 2);
-   STATIC_ASSERT(((FIRST_CHUNK_KEYS-1) * sizeof(gpointer)) == 8);
-#endif
-
    memmove(&first->keys[1], &first->keys[0], (FIRST_CHUNK_KEYS-1));
    memmove(&first->children[1], &first->children[0], (FIRST_CHUNK_KEYS-1) * sizeof(DzlTrieNode *));
 
@@ -488,14 +487,6 @@ dzl_trie_new (GDestroyNotify value_destroy)
 {
    DzlTrie *trie;
 
-#ifdef TRIE_64
-   STATIC_ASSERT(sizeof(DzlTrieNode) == 32);
-   STATIC_ASSERT(sizeof(DzlTrieNodeChunk) == 16);
-#else
-   STATIC_ASSERT(sizeof(DzlTrieNode) == 20);
-   STATIC_ASSERT(sizeof(DzlTrieNodeChunk) == 12);
-#endif
-
    trie = g_new0(DzlTrie, 1);
    trie->ref_count = 1;
    trie->root = dzl_trie_node_new(trie, NULL);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]