Add comment about hashmap_delete.

pull/18/head
Stefano Cossu 3 years ago
parent 774694ec6d
commit cdd1eff2ee

@ -248,7 +248,7 @@ static bool resize(struct hashmap *map, size_t new_cap) {
// replaced then it is returned otherwise NULL is returned. This operation // replaced then it is returned otherwise NULL is returned. This operation
// may allocate memory. If the system is unable to allocate additional // may allocate memory. If the system is unable to allocate additional
// memory then NULL is returned and hashmap_oom() returns true. // memory then NULL is returned and hashmap_oom() returns true.
void *hashmap_set(struct hashmap *map, void *item) { void *hashmap_set(struct hashmap *map, const void *item) {
if (!item) { if (!item) {
panic("item is null"); panic("item is null");
} }
@ -419,6 +419,10 @@ bool hashmap_scan(struct hashmap *map,
// is NOT a copy of the item stored in the hash map and can be directly // is NOT a copy of the item stored in the hash map and can be directly
// modified. // modified.
// //
// Note that if hashmap_delete() is called on the hashmap being iterated,
// the buckets are rearranged and the iterator must be reset to 0, otherwise
// unexpected results may be returned after deletion.
//
// This function has not been tested for thread safety. // This function has not been tested for thread safety.
// //
// The function returns true if an item was retrieved; false if the end of the // The function returns true if an item was retrieved; false if the end of the

Loading…
Cancel
Save