new_array[n] = u;
new_array[n+1] = NULL;
- /* Make sure the hashmap is allocated */
- r = hashmap_ensure_allocated(&u->manager->watch_pids_more, &pidref_hash_ops_free);
- if (r < 0)
- return r;
-
/* Add or replace the old array */
- r = hashmap_replace(u->manager->watch_pids_more, old_pid ?: pid, new_array);
+ r = hashmap_ensure_replace(&u->manager->watch_pids_more, &pidref_hash_ops_free, old_pid ?: pid, new_array);
if (r < 0)
return r;
}
}
- r = ordered_hashmap_ensure_allocated(&hwdb->properties, &string_hash_ops);
- if (r < 0)
- return r;
-
- r = ordered_hashmap_replace(hwdb->properties, key, (void *)entry);
+ r = ordered_hashmap_ensure_replace(&hwdb->properties, &string_hash_ops, key, (void *) entry);
if (r < 0)
return r;
}
static int broadcast_group_set_ref(sd_netlink *nl, unsigned group, unsigned n_ref) {
- int r;
-
assert(nl);
- r = hashmap_ensure_allocated(&nl->broadcast_group_refs, NULL);
- if (r < 0)
- return r;
-
- return hashmap_replace(nl->broadcast_group_refs, UINT_TO_PTR(group), UINT_TO_PTR(n_ref));
+ return hashmap_ensure_replace(&nl->broadcast_group_refs, NULL, UINT_TO_PTR(group), UINT_TO_PTR(n_ref));
}
static int broadcast_group_join(sd_netlink *nl, unsigned group) {