Microsoft KB Archive/247653

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 07:59, 21 July 2020 by X010 (talk | contribs) (Text replacement - "<" to "<")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

INFO: If You Call TlsGetValue() on an Uninitialized TLS Slot, a NULL Value May Not Be Returned

Q247653



The information in this article applies to:


  • Microsoft Windows CE Operating System versions 2.0, 2.11, 2.12





SUMMARY

Under Windows CE versions 2.xx, if you call the TlsGetValue function on an uninitialized thread local storage (TLS) slot (that is, TlsSetValue has not yet been called to set a value at the slot), a NULL value may not be returned in all cases. The following is not recommended:

DWORD dwSlot = 0;

if ((dwSlot = TlsAlloc()) == -1)
{
    // Do error handling here.
}

if (TlsGetValue(dwSlot) != NULL)    // <== BAD assumption.
{
    // Assume slot contains valid data.
}

TlsFree(dwSlot); 

This is contrary to certain documentation on the subject. Under Windows 3.0, if you call TlsGetValue on uninitialized TLS slots, NULL is returned.

Additional query words:

Keywords : kbETK kbOSWinCEsearch kbDSupport kbGrpDSETK
Issue type : kbinfo
Technology : kbOSWinCE kbWinCESearch kbWinCE200 kbWinCE211 kbWinCE212


Last Reviewed: June 12, 2001
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.