summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
authorEric Engestrom <[email protected]>2018-10-20 18:00:08 +0100
committerEric Engestrom <[email protected]>2018-10-25 12:43:18 +0100
commitbb84fa146f2252f22999205a2904d8a948bffd3b (patch)
tree2e4773252d67da46590ec4a545fc10f6125043a9 /src/util
parent3d261cf77b35c56cc575ce9bb7909d2f8d920233 (diff)
util: use C99 declaration in the for-loop hash_table_foreach() macro
Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/util')
-rw-r--r--src/util/hash_table.c4
-rw-r--r--src/util/hash_table.h8
-rw-r--r--src/util/tests/hash_table/clear.c1
-rw-r--r--src/util/tests/hash_table/collision.c2
4 files changed, 5 insertions, 10 deletions
diff --git a/src/util/hash_table.c b/src/util/hash_table.c
index 7ee9e18a1fc..fc152f84a4d 100644
--- a/src/util/hash_table.c
+++ b/src/util/hash_table.c
@@ -177,8 +177,6 @@ _mesa_hash_table_destroy(struct hash_table *ht,
return;
if (delete_function) {
- struct hash_entry *entry;
-
hash_table_foreach(ht, entry) {
delete_function(entry);
}
@@ -284,7 +282,7 @@ static void
_mesa_hash_table_rehash(struct hash_table *ht, unsigned new_size_index)
{
struct hash_table old_ht;
- struct hash_entry *table, *entry;
+ struct hash_entry *table;
if (new_size_index >= ARRAY_SIZE(hash_sizes))
return;
diff --git a/src/util/hash_table.h b/src/util/hash_table.h
index 40ff041e94b..d89fc1dc1c8 100644
--- a/src/util/hash_table.h
+++ b/src/util/hash_table.h
@@ -139,9 +139,9 @@ _mesa_fnv32_1a_accumulate_block(uint32_t hash, const void *data, size_t size)
* an entry's data with the deleted marker), but not against insertion
* (which may rehash the table, making entry a dangling pointer).
*/
-#define hash_table_foreach(ht, entry) \
- for (entry = _mesa_hash_table_next_entry(ht, NULL); \
- entry != NULL; \
+#define hash_table_foreach(ht, entry) \
+ for (struct hash_entry *entry = _mesa_hash_table_next_entry(ht, NULL); \
+ entry != NULL; \
entry = _mesa_hash_table_next_entry(ht, entry))
static inline void
@@ -151,8 +151,6 @@ hash_table_call_foreach(struct hash_table *ht,
void *closure),
void *closure)
{
- struct hash_entry *entry;
-
hash_table_foreach(ht, entry)
callback(entry->key, entry->data, closure);
}
diff --git a/src/util/tests/hash_table/clear.c b/src/util/tests/hash_table/clear.c
index 526700bfb0f..3d6bf80c0cf 100644
--- a/src/util/tests/hash_table/clear.c
+++ b/src/util/tests/hash_table/clear.c
@@ -53,7 +53,6 @@ static void delete_function(struct hash_entry *entry)
int main()
{
struct hash_table *ht;
- struct hash_entry *entry;
const uint32_t size = 1000;
bool flags[size];
uint32_t i;
diff --git a/src/util/tests/hash_table/collision.c b/src/util/tests/hash_table/collision.c
index 69a4c29eca7..ba8913281fb 100644
--- a/src/util/tests/hash_table/collision.c
+++ b/src/util/tests/hash_table/collision.c
@@ -37,7 +37,7 @@ main(int argc, char **argv)
const char *str1 = "test1";
const char *str2 = "test2";
const char *str3 = "test3";
- struct hash_entry *entry1, *entry2, *search_entry;
+ struct hash_entry *entry1, *entry2;
uint32_t bad_hash = 5;
int i;