summaryrefslogtreecommitdiff
path: root/ckcapi-session.c
diff options
context:
space:
mode:
Diffstat (limited to 'ckcapi-session.c')
-rw-r--r--ckcapi-session.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/ckcapi-session.c b/ckcapi-session.c
index 064e477..d1d345c 100644
--- a/ckcapi-session.c
+++ b/ckcapi-session.c
@@ -59,7 +59,7 @@ ckcapi_session_create(CK_SLOT_ID slot, CkCapiSession** ret)
if(!sess)
return CKR_HOST_MEMORY;
- sess->object_data = ckcapi_hash_new();
+ sess->object_data = ckcapi_hash_new(NULL, NULL);
if(!sess->object_data) {
free(sess);
return CKR_HOST_MEMORY;
@@ -505,7 +505,7 @@ ckcapi_session_get_object_data(CkCapiSession* sess, CkCapiObject* obj,
id = obj->id;
- *objdata = ckcapi_hash_get(sess->object_data, &id, sizeof(id));
+ *objdata = ckcapi_hash_get(sess->object_data, ckcapi_hash_key(id));
if(*objdata)
return CKR_OK;
@@ -516,8 +516,7 @@ ckcapi_session_get_object_data(CkCapiSession* sess, CkCapiObject* obj,
newdata->object = id;
ASSERT(newdata->data_funcs);
- if(!ckcapi_hash_set(sess->object_data, &newdata->object,
- sizeof(newdata->object), newdata)) {
+ if(!ckcapi_hash_set(sess->object_data, ckcapi_hash_key(id), newdata)) {
object_data_release(newdata);
return CKR_HOST_MEMORY;
}
@@ -535,7 +534,7 @@ ckcapi_session_clear_object_data(CkCapiSession* sess, CkCapiObject* obj)
ASSERT(sess->object_data);
ASSERT(obj);
- objdata = (CkCapiObjectData*)ckcapi_hash_rem(sess->object_data, &obj->id, sizeof(obj->id));
+ objdata = (CkCapiObjectData*)ckcapi_hash_rem(sess->object_data, ckcapi_hash_key(obj->id));
if(objdata)
object_data_release(objdata);
}
@@ -555,7 +554,7 @@ ckcapi_session_enum_object_data(CkCapiSession* sess,
max = ckcapi_token_get_max_handle();
for(i = 0; i < max; ++i)
{
- objdata = (CkCapiObjectData*)ckcapi_hash_get(sess->object_data, &i, sizeof(i));
+ objdata = (CkCapiObjectData*)ckcapi_hash_get(sess->object_data, ckcapi_hash_key(i));
if(!objdata)
continue;
@@ -593,12 +592,11 @@ ckcapi_session_take_object_data(CkCapiSession* sess, CkCapiObject* obj,
ASSERT(objdata);
objdata->object = obj->id;
- prev = ckcapi_hash_rem(sess->object_data, &obj->id, sizeof(obj->id));
+ prev = ckcapi_hash_rem(sess->object_data, ckcapi_hash_key(obj->id));
if(prev)
object_data_release(prev);
- if(!ckcapi_hash_set(sess->object_data, &objdata->object,
- sizeof(objdata->object), objdata))
+ if(!ckcapi_hash_set(sess->object_data, ckcapi_hash_key(obj->id), objdata))
object_data_release(objdata);
}
@@ -686,24 +684,24 @@ void
purge_duplicate_objects(CkCapiArray* arr)
{
CkCapiHash* checks;
- CK_OBJECT_HANDLE* v;
+ CK_OBJECT_HANDLE v;
size_t i;
- checks = ckcapi_hash_new();
+ checks = ckcapi_hash_new(NULL, NULL);
if(!checks)
return;
for(i = 0; i < arr->len; )
{
- v = &ckcapi_array_index(arr, CK_OBJECT_HANDLE, i);
- if(ckcapi_hash_get(checks, v, sizeof(CK_OBJECT_HANDLE)))
+ v = ckcapi_array_index(arr, CK_OBJECT_HANDLE, i);
+ if(ckcapi_hash_get(checks, ckcapi_hash_key(v)))
{
ckcapi_array_remove_index(arr, i);
/* Look at same i again */
}
else
{
- if(!ckcapi_hash_set(checks, v, sizeof(CK_OBJECT_HANDLE), v))
+ if(!ckcapi_hash_set(checks, ckcapi_hash_key(v), arr))
break;
++i;
}