aboutsummaryrefslogtreecommitdiff
path: root/tests/test-qht.c
diff options
context:
space:
mode:
authorEmilio G. Cota <cota@braap.org>2017-07-11 18:48:21 -0400
committerRichard Henderson <richard.henderson@linaro.org>2018-06-15 07:42:55 -1000
commit32359d529f30bea8124ed671b2e6a22f22540488 (patch)
tree937ee3f60e999574e764bcbf29f4aab1960cfe5b /tests/test-qht.c
parent61b8cef1d42567d3029e0c7180cbd0f16cc4be2d (diff)
downloadqemu-32359d529f30bea8124ed671b2e6a22f22540488.zip
qemu-32359d529f30bea8124ed671b2e6a22f22540488.tar.gz
qemu-32359d529f30bea8124ed671b2e6a22f22540488.tar.bz2
qht: return existing entry when qht_insert fails
The meaning of "existing" is now changed to "matches in hash and ht->cmp result". This is saner than just checking the pointer value. Suggested-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Emilio G. Cota <cota@braap.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'tests/test-qht.c')
-rw-r--r--tests/test-qht.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/test-qht.c b/tests/test-qht.c
index b069881..dda6a06 100644
--- a/tests/test-qht.c
+++ b/tests/test-qht.c
@@ -27,11 +27,17 @@ static void insert(int a, int b)
for (i = a; i < b; i++) {
uint32_t hash;
+ void *existing;
+ bool inserted;
arr[i] = i;
hash = i;
- qht_insert(&ht, &arr[i], hash);
+ inserted = qht_insert(&ht, &arr[i], hash, NULL);
+ g_assert_true(inserted);
+ inserted = qht_insert(&ht, &arr[i], hash, &existing);
+ g_assert_false(inserted);
+ g_assert_true(existing == &arr[i]);
}
}