diff options
author | Thomas Haller <thaller@redhat.com> | 2022-08-01 20:44:08 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2022-08-09 08:02:36 +0200 |
commit | e0fc8a11d5310303e680f101604291a4139317dd (patch) | |
tree | 88cfa3722840b1856c042dbb95a65714f11c60ec | |
parent | 49ddb96d4ef78e5289e64bbf9f0d257c7df25873 (diff) | |
download | NetworkManager-e0fc8a11d5310303e680f101604291a4139317dd.tar.gz |
glib-aux: add nm_g_hash_table_contains_any() helper
-rw-r--r-- | src/libnm-glib-aux/nm-shared-utils.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/libnm-glib-aux/nm-shared-utils.h b/src/libnm-glib-aux/nm-shared-utils.h index d8ec065732..3decea9b37 100644 --- a/src/libnm-glib-aux/nm-shared-utils.h +++ b/src/libnm-glib-aux/nm-shared-utils.h @@ -2405,6 +2405,25 @@ nm_g_hash_table_contains(GHashTable *hash, gconstpointer key) return hash ? g_hash_table_contains(hash, key) : FALSE; } +#define nm_g_hash_table_contains_any(hash, ...) \ + ({ \ + GHashTable *const _hash = (hash); \ + gconstpointer const _keys[] = {__VA_ARGS__}; \ + int _i_key; \ + gboolean _contains = FALSE; \ + \ + if (_hash) { \ + for (_i_key = 0; _i_key < (int) G_N_ELEMENTS(_keys); _i_key++) { \ + if (g_hash_table_contains(_hash, _keys[_i_key])) { \ + _contains = TRUE; \ + break; \ + } \ + } \ + } \ + \ + _contains; \ + }) + static inline gboolean nm_g_hash_table_remove(GHashTable *hash, gconstpointer key) { |