diff options
author | Stef Walter <stef@memberwebs.com> | 2008-12-09 03:47:01 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2008-12-09 03:47:01 +0000 |
commit | 94c63a237d77654bab2ea34146b06fd4b0acfc99 (patch) | |
tree | e726b7d285dd9f188ba92830355f64b8cba644ab /ckcapi-builtin.c | |
parent | a71df0e849b4e286f29ae6e26973961d3412cd83 (diff) |
Use better and faster hashing of objects.
Diffstat (limited to 'ckcapi-builtin.c')
-rw-r--r-- | ckcapi-builtin.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/ckcapi-builtin.c b/ckcapi-builtin.c index 1be3ccc..21115a3 100644 --- a/ckcapi-builtin.c +++ b/ckcapi-builtin.c @@ -73,12 +73,6 @@ static CK_ULONG num_builtins = 0; typedef struct _BuiltinObject { CkCapiObject obj; - - /* - * Together these form the unique key. Must be - * laid out together in memory. - */ - unsigned int otype; CK_ATTRIBUTE_PTR attr; } BuiltinObject; @@ -154,6 +148,18 @@ builtin_load_data(CkCapiSession* sess, CkCapiObject* obj, CkCapiObjectData** obj return CKR_OK; } +static unsigned int +builtin_hash_func(CkCapiObject* obj) +{ + return ckcapi_hash_pointer(((BuiltinObject*)obj)->attr); +} + +static int +builtin_equal_func(CkCapiObject* one, CkCapiObject* two) +{ + return ((BuiltinObject*)one)->attr == ((BuiltinObject*)two)->attr; +} + static void builtin_object_release(void* data) { @@ -164,6 +170,8 @@ builtin_object_release(void* data) static const CkCapiObjectVtable builtin_object_vtable = { builtin_load_data, + builtin_hash_func, + builtin_equal_func, builtin_object_release, }; @@ -177,13 +185,10 @@ register_builtin_object(CkCapiSession* sess, CK_ATTRIBUTE_PTR attr, CkCapiObject if(!bobj) return CKR_HOST_MEMORY; - bobj->otype = OBJECT_BUILTIN; bobj->attr = attr; bobj->obj.id = 0; bobj->obj.obj_funcs = &builtin_object_vtable; - bobj->obj.unique_key = UNIQUE_KEY_AT(bobj, otype); - bobj->obj.unique_len = UNIQUE_KEY_LEN(bobj, otype, attr); ret = ckcapi_token_register_object(sess->slot, &(bobj->obj)); if(ret != CKR_OK) |