diff --git a/shared/nm-glib-aux/nm-hash-utils.c b/shared/nm-glib-aux/nm-hash-utils.c index a82125981..cd51bbaf6 100644 --- a/shared/nm-glib-aux/nm-hash-utils.c +++ b/shared/nm-glib-aux/nm-hash-utils.c @@ -185,6 +185,26 @@ nm_pstr_equal (gconstpointer a, gconstpointer b) && nm_streq0 (*s1, *s2)); } +guint +nm_pint_hash (gconstpointer p) +{ + const int *s = p; + + if (!s) + return nm_hash_static (298377461u); + return nm_hash_val (1208815757u, *s); +} + +gboolean +nm_pint_equals (gconstpointer a, gconstpointer b) +{ + const int *s1 = a; + const int *s2 = a; + + return s1 == s2 + || (s1 && s2 && *s1 == *s2); +} + guint nm_pdirect_hash (gconstpointer p) { diff --git a/shared/nm-glib-aux/nm-hash-utils.h b/shared/nm-glib-aux/nm-hash-utils.h index c95cc6db9..21c5e5841 100644 --- a/shared/nm-glib-aux/nm-hash-utils.h +++ b/shared/nm-glib-aux/nm-hash-utils.h @@ -278,6 +278,14 @@ gboolean nm_pstr_equal (gconstpointer a, gconstpointer b); /*****************************************************************************/ +/* nm_pint_*() are for hashing keys that are pointers to int values, + * that is, "const int *" types. */ + +guint nm_pint_hash (gconstpointer p); +gboolean nm_pint_equals (gconstpointer a, gconstpointer b); + +/*****************************************************************************/ + /* this hashes/compares the pointer value that we point to. Basically, * (*((const void *const*) a) == *((const void *const*) b)). */