INFO: If You Call TlsGetValue() on an Uninitialized TLS Slot, a NULL Value May Not Be Returned (247653)
The information in this article applies to:
- Microsoft Windows CE Operating System, Versions 2.12
- Microsoft Windows CE Operating System, Versions 2.11
- Microsoft Windows CE Operating System, Versions 2.0
This article was previously published under Q247653 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.
Modification Type: | Major | Last Reviewed: | 4/14/2004 |
---|
Keywords: | kbinfo KB247653 |
---|
|