diff options
author | Thomas Haller <thaller@redhat.com> | 2020-03-23 21:04:57 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-04-03 11:26:49 +0200 |
commit | b1503d8a724e09ff9fa7ab4ddf70ce1cdfb7462a (patch) | |
tree | c322d6878af51279ec1780998f57439bfa7e6b45 | |
parent | 962ad7f8506ed54073b51bb5485484d532ba92c6 (diff) | |
download | NetworkManager-b1503d8a724e09ff9fa7ab4ddf70ce1cdfb7462a.tar.gz |
shared: add nm_hash_mem() helper
-rw-r--r-- | shared/nm-glib-aux/nm-hash-utils.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/shared/nm-glib-aux/nm-hash-utils.h b/shared/nm-glib-aux/nm-hash-utils.h index 0e64738fb1..1f29413bd9 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, |