title: Why Win32 HeapReAlloc() changes values?
body: <p>I'm writing an app in C using win32 API.
  When I try to enlarge the size of my array, using the HeapRealloc() function, it changes my current values in the array, instead of copying them.
  The code I use to reallocate memory:</p>
  
  <pre><code>BOOL ChangeFeedArraySize(UINT newSize)
  {   
      char tempChar[20] = "";
      PFEED tempArr;
      if (newSize == 1)
      {
          tempArr = (PFEED)HeapAlloc(heap, HEAP_ZERO_MEMORY, sizeof(FEED));
      }
      else
      {
          tempArr = (PFEED)HeapReAlloc(heap, HEAP_ZERO_MEMORY, categoryArray, newSize * sizeof(FEED));
          // FEED - a struct
          // PFEED - a pointer to the struct
          // categoryArray - array to be reallocated
      }
  
      if (tempArr != NULL)
      {
          MessageBox(NULL, ltoa(HeapSize(heap, 0, tempArr),tempChar,10) , "Heap size after reallocation", MB_OK | MB_ICONEXCLAMATION);
          feedArray = tempArr;
          return TRUE;
      }
      else
      {
          return FALSE;
      }
  }
  </code></pre>
  
  <p>Here is the status of the arrays when in breakpoint.
  the feed array shows the current array state.
  the temp array show the new reallocated array state (which is different).</p>
  
  <p><strong>feed array:</strong></p>
  
  <p><a href="http://www.freeimagehosting.net/uploads/526b0b2172.jpg" rel="nofollow noreferrer">feedArray http://www.freeimagehosting.net/uploads/526b0b2172.jpg</a></p>
  
  <p><strong>temp array:</strong> </p>
  
  <p><a href="http://www.freeimagehosting.net/uploads/17858f2e7e.jpg" rel="nofollow noreferrer">tempArray http://www.freeimagehosting.net/uploads/17858f2e7e.jpg</a></p>
  
  <p>Please help..  :\</p>
  
  <p>Link to the function description on <a href="http://msdn.microsoft.com/en-us/library/aa366704(VS.85).aspx" rel="nofollow noreferrer">MSDN</a></p>