mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 01:47:58 +02:00
shared: add nm_pstr_hash() and nm_pstr_equal()
This commit is contained in:
parent
67828918c9
commit
2cda3770a3
2 changed files with 35 additions and 0 deletions
|
|
@ -159,3 +159,27 @@ nm_direct_hash (gconstpointer ptr)
|
|||
{
|
||||
return nm_hash_ptr (ptr);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
guint
|
||||
nm_pstr_hash (gconstpointer p)
|
||||
{
|
||||
const char *const*s = p;
|
||||
|
||||
if (!s)
|
||||
return nm_hash_static (101061439u);
|
||||
return nm_hash_str (*s);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_pstr_equal (gconstpointer a, gconstpointer b)
|
||||
{
|
||||
const char *const*s1 = a;
|
||||
const char *const*s2 = b;
|
||||
|
||||
return (s1 == s2)
|
||||
|| ( s1
|
||||
&& s2
|
||||
&& nm_streq0 (*s1, *s2));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -209,4 +209,15 @@ guint nm_direct_hash (gconstpointer str);
|
|||
guint nm_hash_str (const char *str);
|
||||
guint nm_str_hash (gconstpointer str);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* nm_pstr_*() are for hashing keys that are pointers to strings,
|
||||
* that is, "const char *const*" types, using strcmp(). */
|
||||
|
||||
guint nm_pstr_hash (gconstpointer p);
|
||||
|
||||
gboolean nm_pstr_equal (gconstpointer a, gconstpointer b);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif /* __NM_HASH_UTILS_H__ */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue