return CMP(a->pid, b->pid);
}
-DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR(
- pidref_hash_ops,
- PidRef,
- pidref_hash_func,
- pidref_compare_func,
- pidref_free);
+DEFINE_HASH_OPS(pidref_hash_ops, PidRef, pidref_hash_func, pidref_compare_func);
+
+DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR(pidref_hash_ops_free,
+ PidRef, pidref_hash_func, pidref_compare_func,
+ pidref_free);
#define TAKE_PIDREF(p) TAKE_GENERIC((p), PidRef, PIDREF_NULL)
-extern const struct hash_ops pidref_hash_ops; /* Has destructor call for pidref_free(), i.e. expects heap allocated PidRef as keys */
+extern const struct hash_ops pidref_hash_ops;
+extern const struct hash_ops pidref_hash_ops_free; /* Has destructor call for pidref_free(), i.e. expects heap allocated PidRef as keys */
return sd_bus_error_setf(error, SD_BUS_ERROR_ACCESS_DENIED, "Process " PID_FMT " not owned by target unit's UID. Refusing.", pid);
}
- r = set_ensure_consume(&pids, &pidref_hash_ops, TAKE_PTR(pidref));
+ r = set_ensure_consume(&pids, &pidref_hash_ops_free, TAKE_PTR(pidref));
if (r < 0)
return r;
}
return r;
/* First, insert into the set of PIDs maintained by the unit */
- r = set_ensure_put(&u->pids, &pidref_hash_ops, pid_dup);
+ r = set_ensure_put(&u->pids, &pidref_hash_ops_free, pid_dup);
if (r < 0)
return r;
pid = TAKE_PTR(pid_dup); /* continue with our copy now that we have installed it properly in our set */
/* Second, insert it into the simple global table, see if that works */
- r = hashmap_ensure_put(&u->manager->watch_pids, &pidref_hash_ops, pid, u);
+ r = hashmap_ensure_put(&u->manager->watch_pids, &pidref_hash_ops_free, pid, u);
if (r != -EEXIST)
return r;
new_array[n+1] = NULL;
/* Make sure the hashmap is allocated */
- r = hashmap_ensure_allocated(&u->manager->watch_pids_more, &pidref_hash_ops);
+ r = hashmap_ensure_allocated(&u->manager->watch_pids_more, &pidref_hash_ops_free);
if (r < 0)
return r;