diff options
Diffstat (limited to 'src/libnm-systemd-shared/src/basic/hashmap.c')
-rw-r--r-- | src/libnm-systemd-shared/src/basic/hashmap.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/libnm-systemd-shared/src/basic/hashmap.c b/src/libnm-systemd-shared/src/basic/hashmap.c index f68cd36bb7..322b148b31 100644 --- a/src/libnm-systemd-shared/src/basic/hashmap.c +++ b/src/libnm-systemd-shared/src/basic/hashmap.c @@ -9,6 +9,7 @@ #include "alloc-util.h" #include "fileio.h" #include "hashmap.h" +#include "logarithm.h" #include "macro.h" #include "memory-util.h" #include "mempool.h" @@ -372,8 +373,9 @@ static void get_hash_key(uint8_t hash_key[HASH_KEY_SIZE], bool reuse_is_ok) { } static struct hashmap_base_entry* bucket_at(HashmapBase *h, unsigned idx) { - return (struct hashmap_base_entry*) - ((uint8_t*) storage_ptr(h) + idx * hashmap_type_info[h->type].entry_size); + return CAST_ALIGN_PTR( + struct hashmap_base_entry, + (uint8_t *) storage_ptr(h) + idx * hashmap_type_info[h->type].entry_size); } static struct plain_hashmap_entry* plain_bucket_at(Hashmap *h, unsigned idx) { @@ -772,7 +774,7 @@ static struct HashmapBase* hashmap_base_new(const struct hash_ops *hash_ops, enu HashmapBase *h; const struct hashmap_type_info *hi = &hashmap_type_info[type]; - bool use_pool = mempool_enabled && mempool_enabled(); + bool use_pool = mempool_enabled && mempool_enabled(); /* mempool_enabled is a weak symbol */ h = use_pool ? mempool_alloc0_tile(hi->mempool) : malloc0(hi->head_size); if (!h) @@ -1751,7 +1753,7 @@ HashmapBase* _hashmap_copy(HashmapBase *h HASHMAP_DEBUG_PARAMS) { } if (r < 0) - return _hashmap_free(copy, false, false); + return _hashmap_free(copy, NULL, NULL); return copy; } |