858
Appendix A: System Routines — Memory Management
TI
-
89 / TI
-
92 Plus Developer Guide
Not for Distribution
Beta Version January 26, 2001
HeapPtrToHandle
Declaration:
HANDLE
HeapPtrToHandle
(void const *
ptr
)
Category(ies):
Memory Management
Description:
Find the handle associated with a dereferenced pointer by searching the
table of handle pointers for the given pointer.
Inputs:
ptr
— A dereferenced pointer to the heap.
Outputs:
HANDLE of dereferenced pointer or H_NULL if not found.
Assumptions:
The heap has not been compressed since the dereferenced pointer was
originally obtained or the block it points to is locked.
Side Effects:
This routine searches the entire handle table and so should be used
accordingly.
Availability:
All versions of the TI
-
89 / TI
-
92 Plus.
TI
-
89 / TI
-
92 Plus
Differences:
None
See Also:
None
Example:
HANDLE h1, h2;
void *Ptr;
if (h1 = HeapAlloc(1000)) {
Ptr = HLock( h1 ); /* Lock handle, return pointer to memory */
h2 = HeapPtrToHandle( Ptr ); /* h2 better be same as h1 */
if (h1 != h2)
DlgMessage("ERROR", "Pointers do not match", PDB_CANCEL, 0 );
HeapFree( h1 ); /* do not have to unlock it to free it */
}