pk11queue_delete(object,object->handle,slot->tokObjects, slot->tokObjHashSize);
pk11queue_delete2(object, object->handle, index, slot->tokObjects);
pk11_DeleteObject(PK11Session *session, PK11Object *object){    PK11Slot *slot = pk11_SlotFromSession(session);    PK11SessionObject *so = pk11_narrowToSessionObject(object);    PK11TokenObject *to = pk11_narrowToTokenObject(object);    CK_RV crv = CKR_OK;    SECStatus rv;    NSSLOWCERTCertificate *cert;    NSSLOWCERTCertTrust tmptrust;    PRBool isKrl;  /* Handle Token case */    if (so && so->session) {	PK11Session *session = so->session;	PK11_USE_THREADS(PZ_Lock(session->objectLock);)	pk11queue_delete(&so->sessionList,0,session->objects,0);	PK11_USE_THREADS(PZ_Unlock(session->objectLock);)	PK11_USE_THREADS(PZ_Lock(slot->objectLock);)	pk11queue_delete(object,object->handle,slot->tokObjects,						slot->tokObjHashSize);	PK11_USE_THREADS(PZ_Unlock(slot->objectLock);)	pk11_FreeObject(object); /* reduce it's reference count */    } else {	PORT_Assert(to);	/* remove the objects from the real data base */	switch (object->handle & PK11_TOKEN_TYPE_MASK) {	case PK11_TOKEN_TYPE_PRIV:	case PK11_TOKEN_TYPE_KEY:	    /* KEYID is the public KEY for DSA and DH, and the MODULUS for	     *  RSA */	    PORT_Assert(slot->keyDB);	    rv = nsslowkey_DeleteKey(slot->keyDB, &to->dbKey);	    if (rv != SECSuccess) crv= CKR_DEVICE_ERROR;	    break;	case PK11_TOKEN_TYPE_PUB:	    break; /* public keys only exist at the behest of the priv key */	case PK11_TOKEN_TYPE_CERT:	    cert = nsslowcert_FindCertByKey(slot->certDB,&to->dbKey);	    if (cert == NULL) {		crv = CKR_DEVICE_ERROR;		break;	    }	    rv = nsslowcert_DeletePermCertificate(cert);	    if (rv != SECSuccess) crv = CKR_DEVICE_ERROR;	    nsslowcert_DestroyCertificate(cert);	    break;	case PK11_TOKEN_TYPE_CRL:	    isKrl = (PRBool) (object->handle == PK11_TOKEN_KRL_HANDLE);	    rv = nsslowcert_DeletePermCRL(slot->certDB,&to->dbKey,isKrl);	    if (rv == SECFailure) crv = CKR_DEVICE_ERROR;	    break;	case PK11_TOKEN_TYPE_TRUST:	    cert = nsslowcert_FindCertByKey(slot->certDB,&to->dbKey);	    if (cert == NULL) {		crv = CKR_DEVICE_ERROR;		break;	    }	    tmptrust = *cert->trust;	    tmptrust.sslFlags &= CERTDB_PRESERVE_TRUST_BITS;	    tmptrust.emailFlags &= CERTDB_PRESERVE_TRUST_BITS;	    tmptrust.objectSigningFlags &= CERTDB_PRESERVE_TRUST_BITS;	    tmptrust.sslFlags |= CERTDB_TRUSTED_UNKNOWN;	    tmptrust.emailFlags |= CERTDB_TRUSTED_UNKNOWN;	    tmptrust.objectSigningFlags |= CERTDB_TRUSTED_UNKNOWN;	    rv = nsslowcert_ChangeCertTrust(slot->certDB,cert,&tmptrust);	    if (rv != SECSuccess) crv = CKR_DEVICE_ERROR;	    nsslowcert_DestroyCertificate(cert);	    break;	default:	    break;	}	pk11_tokenKeyLock(object->slot);	pk11_deleteTokenKeyByHandle(object->slot,object->handle);	pk11_tokenKeyUnlock(object->slot);    }     return crv;}