mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 17:53:56 -06:00
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>
This commit is contained in:
parent
61b8cef1d4
commit
32359d529f
5 changed files with 32 additions and 16 deletions
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue