Appendix A: System Routines — Memory Management
859
TI
-
89 / TI
-
92 Plus Developer Guide
Not for Distribution
Beta Version January 26, 2001
HeapRealloc
Declaration:
HANDLE
HeapRealloc
(HANDLE
handle
, DWORD
NewHsize
)
Category(ies):
Memory Management
Description:
Try to reallocate the given heap block to a new size. If
handle
is H_NULL,
then just calls
HeapAlloc
. Return H_NULL if there is not enough memory
(will try to compress the heap first) or the new size is invalid; otherwise
return
handle
(will not change). If the block is LOCKED then it will not be
moved for reallocation! The contents of the object will be unchanged up to
the lesser of the new and old size. If the new size is larger the value of the
newly allocated portion of the object is indeterminate.
Inputs:
handle
— Handle of a heap block allocated with one of the heap
allocation routines.
NewHsize —
Length of block of memory to allocate (all odd sizes are
rounded up to be even).
Outputs:
Return
handle
if successful or H_NULL if not enough memory or invalid
NewHsize
.
Assumptions:
None
Side Effects:
May cause heap compression.
Availability:
All versions of the TI
-
89 / TI
-
92 Plus.
TI
-
89 / TI
-
92 Plus
Differences:
None
See Also: HeapAlloc, HeapAllocThrow, HeapFree
Example:
HANDLE hBlock;
DWORD size = 1000;
if (hBlock = HeapAlloc( size )) {
/* . . . use hBlock . . . */
size = 100; /* shrink block down */
HeapRealloc( hBlock, size ); /* making smaller so will always succeed */
return( hBlock ); /* assume caller will free it */
}