Add hashing.
This commit is contained in:
parent
6f0f55365b
commit
0ed91e92d1
7 changed files with 109 additions and 4 deletions
15
src/object.c
15
src/object.c
|
@ -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 = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue