From 63545d31ca656dd2a81cc5c91444334c19ef34be Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 26 Mar 2020 14:06:57 +0100 Subject: [PATCH] shared: add nm_g_hash_table_*() utils for accepting %NULL hash argument --- shared/nm-glib-aux/nm-shared-utils.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/shared/nm-glib-aux/nm-shared-utils.h b/shared/nm-glib-aux/nm-shared-utils.h index 0d5f383de0..1804081a54 100644 --- a/shared/nm-glib-aux/nm-shared-utils.h +++ b/shared/nm-glib-aux/nm-shared-utils.h @@ -1309,6 +1309,26 @@ char *nm_utils_g_slist_strlist_join (const GSList *a, const char *separator); /*****************************************************************************/ +static inline guint +nm_g_hash_table_size (GHashTable *hash) +{ + return hash ? g_hash_table_size (hash) : 0u; +} + +static inline gpointer +nm_g_hash_table_lookup (GHashTable *hash, gconstpointer key) +{ + return hash ? g_hash_table_lookup (hash, key) : NULL; +} + +static inline gboolean +nm_g_hash_table_remove (GHashTable *hash, gconstpointer key) +{ + return hash ? g_hash_table_remove (hash, key) : FALSE; +} + +/*****************************************************************************/ + gssize nm_utils_ptrarray_find_binary_search (gconstpointer *list, gsize len, gconstpointer needle,