PLArenaPool *arena = NULL;
pk11_DestroyObject(PK11Object *object){#if defined(REF_COUNT_ATTRIBUTE) || defined(NO_ARENA)    int i;#endif    SECItem pubKey;    CK_RV crv = CKR_OK;    SECStatus rv;    PLArenaPool *arena = NULL;    PORT_Assert(object->refCount == 0);    /* delete the database value */    if (object->inDB) {	if (pk11_isToken(object->handle)) {	/* remove the objects from the real data base */	    switch (object->handle & PK11_TOKEN_TYPE_MASK) {	      case PK11_TOKEN_TYPE_PRIV:		/* KEYID is the public KEY for DSA and DH, and the MODULUS for		 *  RSA */		crv=pk11_Attribute2SecItem(NULL,&pubKey,object,CKA_NETSCAPE_DB);		if (crv != CKR_OK) break;		rv = SECKEY_DeleteKey(SECKEY_GetDefaultKeyDB(), &pubKey);		if (rv != SECSuccess && pubKey.data[0] == 0) {		    /* Because of legacy code issues, sometimes the public key		     * has a '0' prepended to it, forcing it to be unsigned.	             * The database may not store that '0', so remove it and		     * try again.		     */		    SECItem tmpPubKey;		    tmpPubKey.data = pubKey.data + 1;		    tmpPubKey.len = pubKey.len - 1;		    rv = SECKEY_DeleteKey(SECKEY_GetDefaultKeyDB(), &tmpPubKey);		}		if (rv != SECSuccess) crv= CKR_DEVICE_ERROR;		break;	      case PK11_TOKEN_TYPE_CERT:		rv = SEC_DeletePermCertificate((CERTCertificate *)object->objectInfo);		if (rv != SECSuccess) crv = CKR_DEVICE_ERROR;		break;	    }	}    }     if (object->label) PORT_Free(object->label);    object->inDB = PR_FALSE;    object->label = NULL;#ifdef NO_ARENA    for (i=0; i < MAX_OBJS_ATTRS; i++) {	unsigned char *value = object->attrList[i].attrib.pValue;	if (value) {	    PORT_Memset(value,0,object->attrList[i].attrib.ulValueLen);	    if (value != object->attrList[i].space) {		PORT_Free(value);	    }	    object->attrList[i].attrib.pValue = NULL;	}    }#endif#ifdef REF_COUNT_ATTRIBUTE    /* clean out the attributes */    /* since no one is referencing us, it's safe to walk the chain     * without a lock */    for (i=0; i < ATTRIBUTE_HASH_SIZE; i++) {	PK11Attribute *ap,*next;	for (ap = object->head[i]; ap != NULL; ap = next) {	    next = ap->next;	    /* paranoia */	    ap->next = ap->prev = NULL;	    pk11_FreeAttribute(ap);	}	object->head[i] = NULL;    }#endif    if (object->objectInfo) {	(*object->infoFree)(object->objectInfo);    }#ifdef NO_ARENA    pk11_PutObjectToList(object);#else    PK11_USE_THREADS(PZ_DestroyLock(object->attributeLock);)    PK11_USE_THREADS(PZ_DestroyLock(object->refLock);)    arena = object->arena;    PORT_FreeArena(arena,PR_FALSE);#endif    return crv;}