current->type = certRFC822Name;
AddSubjectAltNames(void *extHandle, const char *names, CERTGeneralNameType type){    SECItem item = { 0, NULL, 0 };    CERTGeneralName *nameList = NULL;    CERTGeneralName *current = NULL;    PRCList *prev = NULL;    PRArenaPool *arena;    const char *cp;    char *tbuf;    SECStatus rv = SECSuccess;    arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);    if (arena == NULL) {	return SECFailure;    }	    /*     * walk down the comma separated list of names. NOTE: there is     * no sanity checks to see if the email address look like email addresses.     */    for (cp=names; cp; cp = PORT_Strchr(cp,',')) {	int len;	char *end;	if (*cp == ',') {	   cp++;	}	end = PORT_Strchr(cp,',');	len = end ? end-cp : PORT_Strlen(cp);	if (len <= 0) {	   continue;	}	tbuf = PORT_ArenaAlloc(arena,len+1);	PORT_Memcpy(tbuf,cp,len);	tbuf[len] = 0;	current = (CERTGeneralName *) PORT_ZAlloc(sizeof(CERTGeneralName));	if (!current) {	    rv = SECFailure;	    break;	}	if (prev) {	    current->l.prev = prev;	    prev->next = &(current->l);	} else {	    nameList = current;	}	current->type = type;	current->type = certRFC822Name;	current->name.other.data = (unsigned char *)tbuf;	current->name.other.len = PORT_Strlen(tbuf);	prev = &(current->l);    }    if (rv != SECSuccess) {	goto loser;    }    /* no email address */    if (!nameList) {	/*rv=SECSuccess; We know rv is SECSuccess because of the previous if*/	goto done;     }    nameList->l.prev = prev;    current->l.next = &(nameList->l);    CERT_EncodeAltNameExtension(arena, nameList, &item);    rv = CERT_AddExtension (extHandle, SEC_OID_X509_SUBJECT_ALT_NAME, &item, 							PR_FALSE, PR_TRUE);done:loser:    PORT_FreeArena(arena, PR_FALSE);    return rv;}