From 489e346e87d8c63e563bda2e001039121b805771 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 20 Jun 2017 10:19:37 +0200 Subject: [PATCH] shared: add NM_HASH_COMBINE() function --- shared/nm-utils/nm-macros-internal.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/shared/nm-utils/nm-macros-internal.h b/shared/nm-utils/nm-macros-internal.h index 011f45d0ee..05e3ed7631 100644 --- a/shared/nm-utils/nm-macros-internal.h +++ b/shared/nm-utils/nm-macros-internal.h @@ -381,6 +381,15 @@ _NM_IN_STRSET_streq (const char *x, const char *s) /*****************************************************************************/ +static inline guint +NM_HASH_COMBINE (guint h, guint val) +{ + /* see g_str_hash() for reasons */ + return (h << 5) + h + val; +} + +/*****************************************************************************/ + /* NM_CACHED_QUARK() returns the GQuark for @string, but caches * it in a static variable to speed up future lookups. *