mirror of
https://github.com/mborgerson/xemu.git
synced 2025-12-01 16:10:01 +00: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:
committed by
Richard Henderson
parent
61b8cef1d4
commit
32359d529f
@ -70,6 +70,7 @@ void qht_destroy(struct qht *ht);
|
||||
* @ht: QHT to insert to
|
||||
* @p: pointer to be inserted
|
||||
* @hash: hash corresponding to @p
|
||||
* @existing: address where the pointer to an existing entry can be copied to
|
||||
*
|
||||
* Attempting to insert a NULL @p is a bug.
|
||||
* Inserting the same pointer @p with different @hash values is a bug.
|
||||
@ -78,9 +79,11 @@ void qht_destroy(struct qht *ht);
|
||||
* inserted into the hash table.
|
||||
*
|
||||
* Returns true on success.
|
||||
* Returns false if the @p-@hash pair already exists in the hash table.
|
||||
* Returns false if there is an existing entry in the table that is equivalent
|
||||
* (i.e. ht->cmp matches and the hash is the same) to @p-@h. If @existing
|
||||
* is !NULL, a pointer to this existing entry is copied to it.
|
||||
*/
|
||||
bool qht_insert(struct qht *ht, void *p, uint32_t hash);
|
||||
bool qht_insert(struct qht *ht, void *p, uint32_t hash, void **existing);
|
||||
|
||||
/**
|
||||
* qht_lookup_custom - Look up a pointer using a custom comparison function.
|
||||
|
||||
Reference in New Issue
Block a user