title: C++ TLS, somethings wrong
body: <p>I'm learning about Thread Local Storage... (TLS)
  Here is my TLS Alloc code:</p>
  
  <pre><code>//global variable
  DWORD g_dwTlsIndex;
  
  //inside DLLMain:
  int val= 5;
   switch (ul_reason_for_call)
   {
   case DLL_PROCESS_ATTACH:
    g_dwTlsIndex = TlsAlloc();
  
    if ((g_dwTlsIndex = TlsAlloc()) == TLS_OUT_OF_INDEXES)
    {
     printf("No more indexes available");
    }
  
    void *pint;
    memcpy(&amp;pint, &amp;val, sizeof val);
  
    TlsSetValue(g_dwTlsIndex, pint);
    break;
  </code></pre>
  
  <p>Now I try to get the value from the TLS: (in another CPP file)</p>
  
  <pre><code>// declare index value...
  extern DWORD g_dwTlsIndex;
  
     int  data;
   LPVOID d;
   d = TlsGetValue(g_dwTlsIndex);
   memcpy(&amp;data, &amp;d, sizeof d);
  
   printf("Data: %d", data);
  </code></pre>
  
  <p>But data contains 0, where I put 5 in it.... What have I done wrong?</p>