/** * gck_slot_hash: * @slot: A pointer to a GckSlot * * Create a hash value for the GckSlot. * * This function is intended for easily hashing a GckSlot to add to * a GHashTable or similar data structure. * * Return value: An integer that can be used as a hash value, or 0 if invalid. **/ guint gck_slot_hash (gconstpointer slot) { GckSlot *self; g_return_val_if_fail (GCK_IS_SLOT (slot), 0); self = GCK_SLOT (slot); return _gck_ulong_hash (&self->pv->handle) ^ gck_module_hash (self->pv->module); }
static void test_module_equals_hash (Test *test, gconstpointer unused) { GckModule *other; GObject *obj; guint hash; hash = gck_module_hash (test->module); g_assert (hash != 0); g_assert (gck_module_equal (test->module, test->module)); other = gck_module_new (gck_module_get_functions (test->module)); obj = g_object_new (G_TYPE_OBJECT, NULL); g_assert (gck_module_equal (test->module, other)); /* TODO: Could do with another test for inequality */ g_assert (!gck_module_equal (test->module, obj)); g_object_unref (other); g_object_unref (obj); }