Description
The thread-local memory area consists of 32 DWORDs (128 bytes), each DWORD being 32-bits in size. Up to 8 DWORDs (32 bytes) can be requested each time this function is called. If you want to allocate more than 8 DWORDs, you must call this function more than once.
Allocation is by DWORD only. If you want to store a BYTE in the thread-local memory area, you would still allocate a DWORD, then store the BYTE in it.
#define INCL_DOSPROCESS /* Memory Manager values */
#include <os2.h>
#include <stdio.h> /* For printf */
PVOID pMemBlock; /* Pointer to the memory block returned */
APIRET rc; /* Return code */
rc = DosAllocThreadLocalMemory(6, &pMemBlock); /* Allocate 6 DWORDs */
if (rc != NO_ERROR)
{
printf("DosAllocThreadLocalMemory error: return code = %ld", rc);
return 1;
}
/* ... Use the thread-local memory block ... */
rc = DosFreeThreadLocalMemory(pMemBlock); /* Free the memory block */
if (rc != NO_ERROR)
{
printf("DosFreeThreadLocalMemory error: return code = %ld", rc);
return 1;
}
return 0;