From b1503d8a724e09ff9fa7ab4ddf70ce1cdfb7462a Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 23 Mar 2020 21:04:57 +0100 Subject: [PATCH] shared: add nm_hash_mem() helper --- shared/nm-glib-aux/nm-hash-utils.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/shared/nm-glib-aux/nm-hash-utils.h b/shared/nm-glib-aux/nm-hash-utils.h index 0e64738fb..1f29413bd 100644 --- a/shared/nm-glib-aux/nm-hash-utils.h +++ b/shared/nm-glib-aux/nm-hash-utils.h @@ -266,6 +266,18 @@ guint nm_str_hash (gconstpointer str); nm_hash_complete (&_h); \ }) +static inline guint +nm_hash_mem (guint static_seed, const void *ptr, gsize n) +{ + NMHashState h; + + if (n == 0) + return nm_hash_static (static_seed); + nm_hash_init (&h, static_seed); + nm_hash_update (&h, ptr, n); + return nm_hash_complete (&h); +} + /*****************************************************************************/ /* nm_pstr_*() are for hashing keys that are pointers to strings,