diff options
author | Susant Sahani <ssahani@vmware.com> | 2021-01-14 06:19:47 +0100 |
---|---|---|
committer | Susant Sahani <ssahani@gmail.com> | 2021-01-15 14:29:42 +0100 |
commit | 1346c36d5afa48a39b36485d80552fc1ae24ed12 (patch) | |
tree | 7cebd564f08713dfcbca5170c92f6fb825c4e386 /src/basic/hashmap.c | |
parent | 65ca9b53431aa4c75f9cb1436586655847ed78b7 (diff) | |
download | systemd-1346c36d5afa48a39b36485d80552fc1ae24ed12.tar.gz |
basic: introuce hashmap_ensure_put
Diffstat (limited to 'src/basic/hashmap.c')
-rw-r--r-- | src/basic/hashmap.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/basic/hashmap.c b/src/basic/hashmap.c index cdc6847edf..c118289b99 100644 --- a/src/basic/hashmap.c +++ b/src/basic/hashmap.c @@ -845,6 +845,16 @@ int _set_ensure_allocated(Set **s, const struct hash_ops *hash_ops HASHMAP_DEBU return hashmap_base_ensure_allocated((HashmapBase**)s, hash_ops, HASHMAP_TYPE_SET HASHMAP_DEBUG_PASS_ARGS); } +int _hashmap_ensure_put(Hashmap **h, const struct hash_ops *hash_ops, const void *key, void *value HASHMAP_DEBUG_PARAMS) { + int r; + + r = _hashmap_ensure_allocated(h, hash_ops HASHMAP_DEBUG_PASS_ARGS); + if (r < 0) + return r; + + return hashmap_put(*h, key, value); +} + int _ordered_hashmap_ensure_put(OrderedHashmap **h, const struct hash_ops *hash_ops, const void *key, void *value HASHMAP_DEBUG_PARAMS) { int r; |