From 07045b58058b3066e2acc2a4d5efbb4f0bf4b1b1 Mon Sep 17 00:00:00 2001 From: Igor Putovny Date: Wed, 11 Jun 2025 17:44:38 +0200 Subject: [PATCH] Assert that hash table is not being modified during HASH_WALK According to measurements of hash_test, hash table with this assertion added was not found to be significantly slower than without it on average. Therefore we conclude that this addition would not hamper the performance of HASH_WALK. --- lib/hash.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/hash.h b/lib/hash.h index 3c173958f..4c05c6d7e 100644 --- a/lib/hash.h +++ b/lib/hash.h @@ -165,10 +165,11 @@ #define HASH_WALK(v,next,n) \ do { \ HASH_TYPE(v) *n; \ + const uint _count = v.count; \ uint _i; \ uint _s = HASH_SIZE(v); \ for (_i = 0; _i < _s; _i++) \ - for (n = (v).data[_i]; n; n = n->next) + for (n = (v).data[_i]; ({ ASSERT_DIE(v.count == _count); }), n; n = n->next) #define HASH_WALK_END } while (0) -- 2.47.2