nsCRT::memset(certReqMsgs, 0, sizeof(CRMFCertReqMsg*)*(1+numRequests));
memset(certReqMsgs, 0, sizeof(CRMFCertReqMsg*)*(1+numRequests));
nsCreateReqFromKeyPairs(nsKeyPairInfo *keyids, PRInt32 numRequests,                        char *reqDN, char *regToken, char *authenticator,                        nsNSSCertificate *wrappingCert) {  // We'use the goto notation for clean-up purposes in this function  // that calls the C API of NSS.  PRInt32 i;  // The ASN1 encoder in NSS wants the last entry in the array to be  // NULL so that it knows when the last element is.  CRMFCertReqMsg **certReqMsgs = new CRMFCertReqMsg*[numRequests+1];  CRMFCertRequest *certReq;  if (!certReqMsgs)    return nsnull;  nsCRT::memset(certReqMsgs, 0, sizeof(CRMFCertReqMsg*)*(1+numRequests));  SECStatus srv;  nsresult rv;  CRMFCertReqMessages messages;  nsCRT::memset(&messages, 0, sizeof(messages));  messages.messages = certReqMsgs;  SECItem *encodedReq;  char *retString;  for (i=0; i<numRequests; i++) {    certReq = nsCreateSingleCertReq(&keyids[i], reqDN, regToken, authenticator,                                    wrappingCert);    if (!certReq)      goto loser;    certReqMsgs[i] = CRMF_CreateCertReqMsg();    if (!certReqMsgs[i])      goto loser;    srv = CRMF_CertReqMsgSetCertRequest(certReqMsgs[i], certReq);    if (srv != SECSuccess)      goto loser;    rv = nsSetProofOfPossession(certReqMsgs[i], &keyids[i]);    if (NS_FAILED(rv))      goto loser;    CRMF_DestroyCertRequest(certReq);  }  encodedReq = SEC_ASN1EncodeItem(nsnull, nsnull, &messages,                                  CRMFCertReqMessagesTemplate);  nsFreeCertReqMessages(certReqMsgs, numRequests);  retString = NSSBase64_EncodeItem (nsnull, nsnull, 0, encodedReq);  SECITEM_FreeItem(encodedReq, PR_TRUE);  return retString;loser:  nsFreeCertReqMessages(certReqMsgs,numRequests);  return nsnull;;}