Add hashing.

This commit is contained in:
Jonathan Schleifer 2012-04-09 16:06:27 +02:00
parent 6f0f55365b
commit 0ed91e92d1
7 changed files with 109 additions and 4 deletions

View file

@ -95,6 +95,17 @@ cfw_equal(void *ptr1, void *ptr2)
return (obj1 == obj2);
}
uint32_t
cfw_hash(void *ptr)
{
CFWObject *obj = ptr;
if (obj->cls->hash != NULL)
return obj->cls->hash(obj);
return (uint32_t)(uintptr_t)ptr;
}
void*
cfw_copy(void *ptr)
{
@ -102,8 +113,8 @@ cfw_copy(void *ptr)
if (obj->cls->copy != NULL)
return obj->cls->copy(obj);
else
return NULL;
return NULL;
}
static CFWClass class = {