if (status != PR_SUCCESS) { goto loser; }
NSSTrustDomain_TraverseCertificates (  NSSTrustDomain *td,  PRStatus (*callback)(NSSCertificate *c, void *arg),  void *arg){    PRStatus status;    NSSToken *token = NULL;    NSSSlot **slots = NULL;    NSSSlot **slotp;    nssPKIObjectCollection *collection = NULL;    nssPKIObjectCallback pkiCallback;    nssUpdateLevel updateLevel;    NSSCertificate **cached = NULL;    nssList *certList;    certList = nssList_Create(NULL, PR_FALSE);    if (!certList) return NULL;    (void *)nssTrustDomain_GetCertsFromCache(td, certList);    cached = get_certs_from_list(certList);    collection = nssCertificateCollection_Create(td, cached);    nssCertificateArray_Destroy(cached);    nssList_Destroy(certList);    if (!collection) {	return (PRStatus *)NULL;    }    /* obtain the current set of active slots in the trust domain */    slots = nssTrustDomain_GetActiveSlots(td, &updateLevel);    if (!slots) {	goto loser;    }    /* iterate over the slots */    for (slotp = slots; *slotp; slotp++) {	/* get the token for the slot, if present */	token = nssSlot_GetToken(*slotp);	if (token) {	    nssSession *session;	    nssTokenSearchType tokenOnly = nssTokenSearchType_TokenOnly;	    /* get a session for the token */	    session = nssTrustDomain_GetSessionForToken(td, token);	    if (!session) {		nssToken_Destroy(token);		goto loser;	    }	    /* perform the traversal */	    status = nssToken_TraverseCertificates(token,	                                           session,	                                           tokenOnly,	                                           collector,	                                           collection);	    nssToken_Destroy(token);	    if (status != PR_SUCCESS) {		goto loser;	    }	}    }    /* Traverse the collection */    pkiCallback.func.cert = callback;    pkiCallback.arg = arg;    status = nssPKIObjectCollection_Traverse(collection, &pkiCallback);    /* clean up */    nssPKIObjectCollection_Destroy(collection);    nssSlotArray_Destroy(slots);    return NULL;loser:    if (slots) {	nssSlotArray_Destroy(slots);    }    if (collection) {	nssPKIObjectCollection_Destroy(collection);    }    return NULL;}