DosFreeThreadLocalMemory
Description
Free memory allocated by DosAllocThreadLocalMemory.
Calling Sequence
APIRET DosFreeThreadLocalMemory
(ULONG ProcNum, PULONG pStatus)
Parameters
ProcNum (ULONG)
- input The processor number for which the status is to be set.
pStatus (PULONG) - input
A pointer to the status for the specified processor.
Returns
DosFreeThreadLocalMemory returns
the following values:
0
87
Remarks
When a process is started, a
small block of memory is set aside to be used as a thread-local memory area.
This memory is at the same virtual address for each thread, but is backed
by different physical memory. This permits each thread to have a small block
of memory that is unique, or local, to that thread.
The thread-local memory area consists of 32 DWORDs (128 bytes), each DWORD
being 32-bits in size.
Related Functions
o
DosAllocThreadLocalMemory
Example Code
The following code example
allocates a thread-local memory block of 6 DWORDs, then frees 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;
[Back: DosAllocThreadLocalMemory]
[Next: DosQuerySysInfo]