The following example initializes the ODPP framework with the path of the error messages file.
memset(&FrmwParameter, 0,
sizeof(
DP_INIT_OP_DEF) * OPERANDS_MAX_SIZE);
#ifndef USE_ODPP_MBCS_CHAR_CALLS
if(NULL == FrmwParameter[0].PV.
pWC)
{
printf("Failed to allocate memory for the error file path");
goto CleanFrmwParams;
}
FrmwParameter[0].PV.
pWC->pParamVal = (ODPP_WCHAR*) malloc(
sizeof(ODPP_WCHAR) * ( FrmwParameter[0].
iValueBufBytes /
sizeof(ODPP_WCHAR)) );
if(NULL == FrmwParameter[0].PV.
pWC->pParamVal)
{
printf("Failed to allocate memory for the error file path");
goto CleanFrmwParams;
}
wcscpy(FrmwParameter[0].PV.
pWC->pParamVal, L
"..\\ErrorDirectory\\");
#else
if(NULL == FrmwParameter[0].PV.
pMC)
{
printf("Failed to allocate memory for the error file path");
goto CleanFrmwParams;
}
FrmwParameter[0].PV.
pMC->pParamVal = (
char *) malloc( FrmwParameter[0].iValueBufBytes );
if(NULL == FrmwParameter[0].PV.
pMC->pParamVal)
{
printf("Failed to allocate memory for the error file path");
goto CleanFrmwParams;;
}
strcpy(FrmwParameter[0].PV.
pMC->pParamVal,
"..\\ErrorDirectory\\");
#endif
FrmwParams.
pParams = &FrmwParameter[0];
if(ODPPSUCCESS != retVal)
{
printf("\nFramework init failed Err=%#x\n", retVal);
goto CleanFrmwParams;
}
Free the memory allocated during Framework initialization
CleanFrmwParams:
{
{
#ifndef USE_ODPP_MBCS_CHAR_CALLS
if(NULL != (FrmwParams.
pParams + sCnt)->PV.pWC)
{
if(NULL != (FrmwParams.
pParams + sCnt)->PV.pWC->pParamVal)
{
free((FrmwParams.
pParams + sCnt)->PV.pWC->pParamVal);
(FrmwParams.
pParams + sCnt)->PV.pWC->pParamVal = NULL;
}
free((FrmwParams.
pParams + sCnt)->PV.pWC);
(FrmwParams.
pParams + sCnt)->PV.pWC = NULL;
}
#else
if(NULL != (FrmwParams.
pParams + sCnt)->PV.pMC)
{
if(NULL != (FrmwParams.
pParams + sCnt)->PV.pMC->pParamVal)
{
free((FrmwParams.
pParams + sCnt)->PV.pMC->pParamVal);
(FrmwParams.
pParams + sCnt)->PV.pMC->pParamVal = NULL;
}
free((FrmwParams.
pParams + sCnt)->PV.pMC);
(FrmwParams.
pParams + sCnt)->PV.pMC = NULL;
}
#endif
}
}