I'm using MFC C++ for my Windows Application, where I need to persist (not in a Database) some data using CMapPtrToPtr. The key is a pointer to a structure (let's call it SIGNAL_DATA* pSignal) and the value is a double array.
The problem is, when I read the value again, it is giving me a garbage/undefined value (not the value I stored).
Sample Code:
In the header file:
CMapPtrToPtr prevZoomValsMap;
double zoomPreVals[2];
In the implementation class:
void funktion1()
{
if(ersteSchleife == FALSE) //first time, it is false
{
SIGNAL_DATA* pSelectedSignal; //properly initialised. verified in debug mode
zoomPreVals[0] = zoomMinSkal; //valid double values. verified in debug mode
zoomPreVals[1] = zoomMaxSkal;
prevZoomVals.SetAt((void*) pSelectedSignal, (void*) zoomPreVals);
ersteSchleife = TRUE;
}
else
{
funktion2();
}
}
In another function, when I read the value as below, I'm getting garbage values.
void funktion2()
{
void *zoomValuesTemp_;
prevZoomValsMap.Lookup((void*) sigTemp, zoomValuesTemp_);
double *zoomValuesTemp = (double*)zoomValuesTemp_;
if(zoomValuesTemp == NULL) //verified in debug mode. never becomes NULL.
{
int aRTD = 10; //dummy assignment.
}
double aValue = zoomValuesTemp[0] ; //Access Violation
}