860
Appendix A: System Routines — Memory Management
TI
-
89 / TI
-
92 Plus Developer Guide
Not for Distribution
Beta Version January 26, 2001
HeapShuffle
Declaration:
void
HeapShuffle
(void)
Category(ies):
Memory Management
Description:
Shuffle the blocks in the heap.
HeapShuffle
is a debugging tool for
tracking down problems with handles in an app. When a nonlocked handle
is dereferenced, the resulting pointer is only valid until a heap compression
is done. Heap compression is done internally when a heap allocation fails
in order to try to coalesce free heap blocks together, then the heap
allocation is retried and that result is returned to the caller. This routine
helps track down such problems by forcing all dereferenced handles to
nonlocked blocks of memory to change instead of the app relying on
memory full cases.
Inputs:
None
Outputs:
None
Assumptions:
None
Side Effects:
The blocks of memory in the heap are rearranged. All dereferenced
handles to nonlocked blocks of memory in the heap must be
redereferenced.
Availability:
On AMS 2.00 and higher.
TI
-
89 / TI
-
92 Plus
Differences:
None
See Also: HeapWalk
Example:
BYTE *bPtr1, *bPtr2;
char buf[128];
HANDLE hBlock1;
if (hBlock1 = HeapAlloc(1000)) {
bPtr1 = HeapDeref( hBlock1 );
HeapShuffle();
bPtr2 = HeapDeref( hBlock1 );
sprintf( buf, "Pointer before/after shuffle: %08lX, %08lX", bPtr1, bPtr2 );
DlgNotice( "HeapShuffle", buf );
}