1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-09-14 09:44:48 +03:00

basic/hashmap,set: propagate allocation location info in _copy()

Also use double space before the tracking args at the end. Without
the comma this looks ugly, but it's a bit better with the double space.
At least it doesn't look like a variable with a type.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2020-06-05 14:55:41 +02:00
parent 35e601d4f9
commit add74e8929
3 changed files with 17 additions and 25 deletions

View File

@@ -1711,13 +1711,13 @@ int _hashmap_move_one(HashmapBase *h, HashmapBase *other, const void *key) {
return 0; return 0;
} }
HashmapBase *_hashmap_copy(HashmapBase *h) { HashmapBase *_hashmap_copy(HashmapBase *h HASHMAP_DEBUG_PARAMS) {
HashmapBase *copy; HashmapBase *copy;
int r; int r;
assert(h); assert(h);
copy = hashmap_base_new(h->hash_ops, h->type HASHMAP_DEBUG_SRC_ARGS); copy = hashmap_base_new(h->hash_ops, h->type HASHMAP_DEBUG_PASS_ARGS);
if (!copy) if (!copy)
return NULL; return NULL;
@@ -1733,10 +1733,8 @@ HashmapBase *_hashmap_copy(HashmapBase *h) {
assert_not_reached("Unknown hashmap type"); assert_not_reached("Unknown hashmap type");
} }
if (r < 0) { if (r < 0)
_hashmap_free(copy, false, false); return _hashmap_free(copy, false, false);
return NULL;
}
return copy; return copy;
} }

View File

@@ -128,13 +128,9 @@ static inline OrderedHashmap *ordered_hashmap_free_free_free(OrderedHashmap *h)
IteratedCache *iterated_cache_free(IteratedCache *cache); IteratedCache *iterated_cache_free(IteratedCache *cache);
int iterated_cache_get(IteratedCache *cache, const void ***res_keys, const void ***res_values, unsigned *res_n_entries); int iterated_cache_get(IteratedCache *cache, const void ***res_keys, const void ***res_values, unsigned *res_n_entries);
HashmapBase *_hashmap_copy(HashmapBase *h); HashmapBase *_hashmap_copy(HashmapBase *h HASHMAP_DEBUG_PARAMS);
static inline Hashmap *hashmap_copy(Hashmap *h) { #define hashmap_copy(h) ((Hashmap*) _hashmap_copy(HASHMAP_BASE(h) HASHMAP_DEBUG_SRC_ARGS))
return (Hashmap*) _hashmap_copy(HASHMAP_BASE(h)); #define ordered_hashmap_copy(h) ((OrderedHashmap*) _hashmap_copy(HASHMAP_BASE(h) HASHMAP_DEBUG_SRC_ARGS))
}
static inline OrderedHashmap *ordered_hashmap_copy(OrderedHashmap *h) {
return (OrderedHashmap*) _hashmap_copy(HASHMAP_BASE(h));
}
int _hashmap_ensure_allocated(Hashmap **h, const struct hash_ops *hash_ops HASHMAP_DEBUG_PARAMS); int _hashmap_ensure_allocated(Hashmap **h, const struct hash_ops *hash_ops HASHMAP_DEBUG_PARAMS);
int _ordered_hashmap_ensure_allocated(OrderedHashmap **h, const struct hash_ops *hash_ops HASHMAP_DEBUG_PARAMS); int _ordered_hashmap_ensure_allocated(OrderedHashmap **h, const struct hash_ops *hash_ops HASHMAP_DEBUG_PARAMS);

View File

@@ -26,9 +26,7 @@ static inline Set *set_free_free(Set *s) {
/* no set_free_free_free */ /* no set_free_free_free */
static inline Set *set_copy(Set *s) { #define set_copy(s) ((Set*) _hashmap_copy(HASHMAP_BASE(h) HASHMAP_DEBUG_SRC_ARGS))
return (Set*) _hashmap_copy(HASHMAP_BASE(s));
}
int _set_ensure_allocated(Set **s, const struct hash_ops *hash_ops HASHMAP_DEBUG_PARAMS); int _set_ensure_allocated(Set **s, const struct hash_ops *hash_ops HASHMAP_DEBUG_PARAMS);
#define set_ensure_allocated(h, ops) _set_ensure_allocated(h, ops HASHMAP_DEBUG_SRC_ARGS) #define set_ensure_allocated(h, ops) _set_ensure_allocated(h, ops HASHMAP_DEBUG_SRC_ARGS)