From 78a135f567fe1fbd1bb9a23a83e2f4bd22ef7dc2 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 9 Oct 2025 21:59:48 +0200 Subject: [PATCH] varlink: move definition of varlink_hash_ops into common code This is truly useful whenever we have to deal with multiple varlink connections. --- src/import/importd.c | 2 -- src/libsystemd/sd-varlink/varlink-util.c | 8 ++++++++ src/libsystemd/sd-varlink/varlink-util.h | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/import/importd.c b/src/import/importd.c index 8603069047a..e9923d93ade 100644 --- a/src/import/importd.c +++ b/src/import/importd.c @@ -130,8 +130,6 @@ static const char* const transfer_type_table[_TRANSFER_TYPE_MAX] = { DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(transfer_type, TransferType); -DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(varlink_hash_ops, void, trivial_hash_func, trivial_compare_func, sd_varlink, sd_varlink_unref); - static Transfer *transfer_unref(Transfer *t) { if (!t) return NULL; diff --git a/src/libsystemd/sd-varlink/varlink-util.c b/src/libsystemd/sd-varlink/varlink-util.c index be7df731437..7ae3a66af25 100644 --- a/src/libsystemd/sd-varlink/varlink-util.c +++ b/src/libsystemd/sd-varlink/varlink-util.c @@ -203,3 +203,11 @@ int varlink_check_privileged_peer(sd_varlink *vl) { return 0; } + +DEFINE_HASH_OPS_WITH_VALUE_DESTRUCTOR( + varlink_hash_ops, + void, + trivial_hash_func, + trivial_compare_func, + sd_varlink, + sd_varlink_unref); diff --git a/src/libsystemd/sd-varlink/varlink-util.h b/src/libsystemd/sd-varlink/varlink-util.h index 3a340b22165..929f5b04cf7 100644 --- a/src/libsystemd/sd-varlink/varlink-util.h +++ b/src/libsystemd/sd-varlink/varlink-util.h @@ -27,3 +27,5 @@ int varlink_server_new( void *userdata); int varlink_check_privileged_peer(sd_varlink *vl); + +extern const struct hash_ops varlink_hash_ops; -- 2.47.3