From fe07d6a404c05cea7d5e13fca8751ac82a7cff0f Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 28 Jun 2018 17:12:54 +0200 Subject: [PATCH] shared: add nm_hash_val() macro A helper macro, to combine the steps for hashing one value. --- shared/nm-utils/nm-hash-utils.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/shared/nm-utils/nm-hash-utils.h b/shared/nm-utils/nm-hash-utils.h index d0bb6cf9b8..7d9620b96c 100644 --- a/shared/nm-utils/nm-hash-utils.h +++ b/shared/nm-utils/nm-hash-utils.h @@ -209,6 +209,15 @@ guint nm_direct_hash (gconstpointer str); guint nm_hash_str (const char *str); guint nm_str_hash (gconstpointer str); +#define nm_hash_val(static_seed, val) \ + ({ \ + NMHashState _h; \ + \ + nm_hash_init (&_h, static_seed); \ + nm_hash_update_val (&_h, val); \ + nm_hash_complete (&_h); \ + }) + /*****************************************************************************/ /* nm_pstr_*() are for hashing keys that are pointers to strings,