From 170b4e05fcf3ecb14b4413ba523704ab4152a2c2 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Tue, 23 Nov 2010 22:56:30 +0000 Subject: [egg] Add utilities so GByteArray can be used in GHashTable. Update xdg pkcs11 module to use these new utils. --- pkcs11/gkm/gkm-util.c | 60 --------------------------------------------------- 1 file changed, 60 deletions(-) (limited to 'pkcs11/gkm') diff --git a/pkcs11/gkm/gkm-util.c b/pkcs11/gkm/gkm-util.c index 6e1f29cb..37561d90 100644 --- a/pkcs11/gkm/gkm-util.c +++ b/pkcs11/gkm/gkm-util.c @@ -67,67 +67,7 @@ /* Only access using atomic operations */ static gint next_handle = 0x00000010; -GkmMemory* -gkm_util_memory_new (gconstpointer data, gsize n_data) -{ - GkmMemory *memory; - - memory = g_malloc (n_data + sizeof (GkmMemory)); - memory->n_data = n_data; - memory->data = memory + 1; - - if (n_data) { - g_assert (data); - memcpy (memory + 1, data, n_data); - } - return memory; -} - -guint -gkm_util_memory_hash (gconstpointer v) -{ - const GkmMemory *memory = v; - const signed char *p; - guint32 h = 0; - gsize i; - - g_assert (memory); - g_assert (memory->data); - p = memory->data; - - /* 31 bit hash function */ - for (i = 0; i < memory->n_data; ++i, ++p) - h = (h << 5) - h + *p; - - return h; -} - -gboolean -gkm_util_memory_equal (gconstpointer v1, gconstpointer v2) -{ - const GkmMemory *memory_1 = v1; - const GkmMemory *memory_2 = v2; - - if (memory_1 == memory_2) - return TRUE; - if (!memory_1 || !memory_2) - return FALSE; - - if (memory_1->n_data != memory_2->n_data) - return FALSE; - - g_assert (memory_1->data); - g_assert (memory_2->data); - - return (memcmp (memory_1->data, memory_2->data, memory_1->n_data) == 0); -} - -void -gkm_util_memory_free (gpointer memory) -{ - g_free (memory); -} gulong* gkm_util_ulong_alloc (gulong value) -- cgit v1.2.1