}
DEFINE_TRIVIAL_CLEANUP_FUNC(VacuumCandidate*, vacuum_candidate_free);
-static Hashmap* vacuum_candidate_hashmap_free(Hashmap *h) {
- return hashmap_free_with_destructor(h, vacuum_candidate_free);
-}
-
-DEFINE_TRIVIAL_CLEANUP_FUNC(Hashmap*, vacuum_candidate_hashmap_free);
+DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(
+ vacuum_candidate_hash_ops,
+ void, trivial_hash_func, trivial_compare_func,
+ VacuumCandidate, vacuum_candidate_free);
static int uid_from_file_name(const char *filename, uid_t *uid) {
const char *p, *e, *u;
}
for (;;) {
- _cleanup_(vacuum_candidate_hashmap_freep) Hashmap *h = NULL;
+ _cleanup_hashmap_free_ Hashmap *h = NULL;
VacuumCandidate *worst = NULL;
uint64_t sum = 0;
if (exclude_fd >= 0 && stat_inode_same(&exclude_st, &st))
continue;
- r = hashmap_ensure_allocated(&h, NULL);
- if (r < 0)
- return log_oom();
-
t = timespec_load(&st.st_mtim);
c = hashmap_get(h, UID_TO_PTR(uid));
return r;
n->oldest_mtime = t;
- r = hashmap_put(h, UID_TO_PTR(uid), n);
+ r = hashmap_ensure_put(&h, &vacuum_candidate_hash_ops, UID_TO_PTR(uid), n);
if (r < 0)
return log_oom();