PORT_Free(newparams); }
secmod_ReadPermDB(char *dbname, char *params, PRBool rw) {    DBT key,data;    int ret;    DB *pkcs11db = NULL;    char **moduleList = NULL;    int moduleCount = 1;    int useCount = SECMOD_STEP;    moduleList = (char **) PORT_ZAlloc(useCount*sizeof(char **));    if (moduleList == NULL) return NULL;    pkcs11db = secmod_OpenDB(dbname,PR_TRUE);    if (pkcs11db == NULL) goto done;    /* read and parse the file or data base */    ret = (*pkcs11db->seq)(pkcs11db, &key, &data, R_FIRST);    if (ret)  goto done;    do {	char *moduleString;	PRBool internal = PR_FALSE;	if ((moduleCount+1) >= useCount) {	    useCount += SECMOD_STEP;	    moduleList = 		(char **)PORT_Realloc(moduleList,useCount*sizeof(char *));	    if (moduleList == NULL) goto done;	    PORT_Memset(&moduleList[moduleCount+1],0,						sizeof(char *)*SECMOD_STEP);	}	moduleString = secmod_DecodeData(params,&data,&internal);	if (internal) {	    moduleList[0] = moduleString;	} else {	    moduleList[moduleCount] = moduleString;	    moduleCount++;	}    } while ( (*pkcs11db->seq)(pkcs11db, &key, &data, R_NEXT) == 0);done:    if (!moduleList[0]) {	moduleList[0] = PR_smprintf(PK11_DEFAULT_INTERNAL_INIT,params,						SECMOD_SLOT_FLAGS);    }    /* deal with trust cert db here */    if (pkcs11db) {	secmod_CloseDB(pkcs11db);    } else {	secmod_AddPermDB(dbname,moduleList[0], rw) ;    }    return moduleList;}