title: C++ MFC - CMapPtrToPtr - SetAt and Lookup
body: <p>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. </p>
  
  <p>The problem is, when I read the value again, it is giving me a garbage/undefined value (not the value I stored).</p>
  
  <p><strong>Sample Code:</strong></p>
  
  <p>In the header file:</p>
  
  <pre><code>CMapPtrToPtr prevZoomValsMap;
  double zoomPreVals[2];
  </code></pre>
  
  <p>In the implementation class:</p>
  
  <pre><code>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();
      }
  }
  </code></pre>
  
  <p>In another function, when I read the value as below, I'm getting garbage values.</p>
  
  <pre><code>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
  }
  </code></pre>