From 1e5977b62f896e844b548c3007ace9e1dfa7f9ed Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Sat, 11 Apr 2020 21:28:04 +0200 Subject: New upstream version 1.23.90 --- shared/nm-glib-aux/nm-hash-utils.h | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'shared/nm-glib-aux/nm-hash-utils.h') diff --git a/shared/nm-glib-aux/nm-hash-utils.h b/shared/nm-glib-aux/nm-hash-utils.h index 21c5e584..9f2e9766 100644 --- a/shared/nm-glib-aux/nm-hash-utils.h +++ b/shared/nm-glib-aux/nm-hash-utils.h @@ -88,15 +88,15 @@ nm_hash_complete (NMHashState *state) /* we don't ever want to return a zero hash. * * NMPObject requires that in _idx_obj_part(), and it's just a good idea. */ - return (((guint) (h >> 32)) ^ ((guint) h)) ?: 1396707757u; + return (((guint) (h >> 32)) ^ ((guint) h)) + ?: 1396707757u; } static inline void nm_hash_update (NMHashState *state, const void *ptr, gsize n) { nm_assert (state); - nm_assert (ptr); - nm_assert (n > 0); + nm_assert (n == 0 || ptr); /* Note: the data passed in here might be sensitive data (secrets), * that we should nm_explicty_zero() afterwards. However, since @@ -267,6 +267,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, @@ -303,6 +315,11 @@ gboolean nm_ppdirect_equal (gconstpointer a, gconstpointer b); /*****************************************************************************/ +guint nm_pgbytes_hash (gconstpointer p); +gboolean nm_pgbytes_equal (gconstpointer a, gconstpointer b); + +/*****************************************************************************/ + #define NM_HASH_OBFUSCATE_PTR_FMT "%016" G_GINT64_MODIFIER "x" /* sometimes we want to log a pointer directly, for providing context/information about -- cgit 1.3.0-6-gf8a5 From d460892bbfece74fb6d3cd846bf6ef548290be41 Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Fri, 8 May 2020 21:40:53 +0200 Subject: New upstream version 1.24.0 --- shared/nm-glib-aux/nm-hash-utils.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'shared/nm-glib-aux/nm-hash-utils.h') diff --git a/shared/nm-glib-aux/nm-hash-utils.h b/shared/nm-glib-aux/nm-hash-utils.h index 9f2e9766..be69bfa8 100644 --- a/shared/nm-glib-aux/nm-hash-utils.h +++ b/shared/nm-glib-aux/nm-hash-utils.h @@ -315,6 +315,9 @@ gboolean nm_ppdirect_equal (gconstpointer a, gconstpointer b); /*****************************************************************************/ +guint nm_gbytes_hash (gconstpointer p); +#define nm_gbytes_equal g_bytes_equal + guint nm_pgbytes_hash (gconstpointer p); gboolean nm_pgbytes_equal (gconstpointer a, gconstpointer b); -- cgit 1.3.0-6-gf8a5