hashmap: honor the value destructor in set_ensure_consume()
Sets store their element in the key slot but use a value destructor
(DEFINE_HASH_OPS_WITH_VALUE_DESTRUCTOR). On the reject/duplicate path
set_ensure_consume() only checked free_key and otherwise called free().
Follow-up for fcc1d0315d
This commit is contained in:
@@ -1330,6 +1330,9 @@ int set_ensure_consume(Set **s, const struct hash_ops *hash_ops, void *key) {
|
||||
if (r <= 0) {
|
||||
if (hash_ops && hash_ops->free_key)
|
||||
hash_ops->free_key(key);
|
||||
else if (hash_ops && hash_ops->free_value)
|
||||
/* Sets store their element in the key slot but may carry a value destructor. */
|
||||
hash_ops->free_value(key);
|
||||
else
|
||||
free(key);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user