DestroyDBEntry((certDBEntry *)entry);
AddPermSubjectNode(certDBEntrySubject *entry, NSSLOWCERTCertificate *cert, 								char *nickname){    SECItem *newCertKeys, *newKeyIDs;    int i;    SECStatus rv;    NSSLOWCERTCertificate *cmpcert;    unsigned int nnlen;    int ncerts;        PORT_Assert(entry);        ncerts = entry->ncerts;	    if ( nickname && entry->nickname ) {	/* nicknames must be the same */	PORT_Assert(PORT_Strcmp(nickname, entry->nickname) == 0);    }    if ( ( entry->nickname == NULL ) && ( nickname != NULL ) ) {	/* copy nickname into the entry */	nnlen = PORT_Strlen(nickname) + 1;	entry->nickname = (char *)PORT_ArenaAlloc(entry->common.arena,nnlen);	if ( entry->nickname == NULL ) {	    return(SECFailure);	}	PORT_Memcpy(entry->nickname, nickname, nnlen);    }	    /* a DB entry already exists, so add this cert */    newCertKeys = (SECItem *)PORT_ArenaAlloc(entry->common.arena,					 sizeof(SECItem) * ( ncerts + 1 ) );    newKeyIDs = (SECItem *)PORT_ArenaAlloc(entry->common.arena,					 sizeof(SECItem) * ( ncerts + 1 ) );    if ( ( newCertKeys == NULL ) || ( newKeyIDs == NULL ) ) {	    return(SECFailure);    }    for ( i = 0; i < ncerts; i++ ) {	cmpcert = nsslowcert_FindCertByKey(cert->dbhandle,						  &entry->certKeys[i]);	PORT_Assert(cmpcert);	if ( nsslowcert_IsNewer(cert, cmpcert) ) {	    /* insert before cmpcert */	    rv = SECITEM_CopyItem(entry->common.arena, &newCertKeys[i],				      &cert->certKey);	    if ( rv != SECSuccess ) {		return(SECFailure);	    }	    rv = SECITEM_CopyItem(entry->common.arena, &newKeyIDs[i],				      &cert->subjectKeyID);	    if ( rv != SECSuccess ) {		return(SECFailure);	    }	    /* copy the rest of the entry */	    for ( ; i < ncerts; i++ ) {		newCertKeys[i+1] = entry->certKeys[i];		newKeyIDs[i+1] = entry->keyIDs[i];	    }	    /* update certKeys and keyIDs */	    entry->certKeys = newCertKeys;	    entry->keyIDs = newKeyIDs;			    /* increment count */	    entry->ncerts++;	    break;	}	/* copy this cert entry */	newCertKeys[i] = entry->certKeys[i];	newKeyIDs[i] = entry->keyIDs[i];    }    if ( entry->ncerts == ncerts ) {	/* insert new one at end */	rv = SECITEM_CopyItem(entry->common.arena, &newCertKeys[ncerts],				  &cert->certKey);	if ( rv != SECSuccess ) {	    return(SECFailure);	}	rv = SECITEM_CopyItem(entry->common.arena, &newKeyIDs[ncerts],				  &cert->subjectKeyID);	if ( rv != SECSuccess ) {	    return(SECFailure);	}	/* update certKeys and keyIDs */	entry->certKeys = newCertKeys;	entry->keyIDs = newKeyIDs;			/* increment count */	entry->ncerts++;    }    DeleteDBSubjectEntry(cert->dbhandle, &cert->derSubject);    rv = WriteDBSubjectEntry(cert->dbhandle, entry);    DestroyDBEntry((certDBEntry *)entry);    return(rv);}