aboutsummaryrefslogtreecommitdiff
path: root/src/std
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-08-21 06:08:00 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-25 14:36:46 +0200
commitc68fe7634341e97c3246b627a20fa9487586ffcb (patch)
tree78d499cc090439fa8fe087105e52f771d7728d23 /src/std
parentf24139d455af3a179fe1d19c951e4cd85744c592 (diff)
hash map contains
Diffstat (limited to 'src/std')
-rw-r--r--src/std/hash_map.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/std/hash_map.c b/src/std/hash_map.c
index 2b29f2e..48e9e38 100644
--- a/src/std/hash_map.c
+++ b/src/std/hash_map.c
@@ -192,7 +192,8 @@ bool hash_map_get(HashMap *self, BufferView key, void *value) {
BufferView bucket_key;
bucket_key = bucket_node_get_key(bucket_node);
if(hash == bucket_node_get_hash(bucket_node) && self->compare_func(&key, &bucket_key) == 0) {
- am_memcpy(value, bucket_node_get_value(bucket_node), self->value_type_size);
+ if(value)
+ am_memcpy(value, bucket_node_get_value(bucket_node), self->value_type_size);
return bool_true;
}
}
@@ -200,6 +201,10 @@ bool hash_map_get(HashMap *self, BufferView key, void *value) {
return bool_false;
}
+bool hash_map_contains(HashMap *self, BufferView key) {
+ return hash_map_get(self, key, NULL);
+}
+
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int hash_map_compare_string(const void *a, const void *b) {