core,clients: use our own string hashing function nm_str_hash()

Replace the usage of g_str_hash() with our own nm_str_hash().

GLib's g_str_hash() uses djb2 hashing function, just like we
do at the moment. The only difference is, that we use a diffrent
seed value.

Note, that we initialize the hash seed with random data (by calling
getrandom() or reading /dev/urandom). That is a change compared to
before.

This change of the hashing function and accessing the random pool
might be undesired for libnm/libnm-core. Hence, the change is not
done there as it possibly changes behavior for public API. Maybe
we should do that later though.

At this point, there isn't much of a change. This patch becomes
interesting, if we decide to use a different hashing algorithm.
This commit is contained in:
Thomas Haller
2017-10-13 16:12:35 +02:00
parent 0e9e35e309
commit 3434261811
43 changed files with 93 additions and 76 deletions

View File

@@ -24,6 +24,7 @@
#include <string.h>
#include "nm-utils/nm-hash-utils.h"
#include "nm-setting-connection.h"
#include "nm-auth-subject.h"
#include "nm-auth-manager.h"
@@ -131,7 +132,7 @@ nm_auth_chain_new_subject (NMAuthSubject *subject,
self = g_slice_new0 (NMAuthChain);
self->refcount = 1;
self->data = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, chain_data_free);
self->data = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, chain_data_free);
self->done_func = done_func;
self->user_data = user_data;
self->context = context ? g_object_ref (context) : NULL;