ReallocHandle
Handle theHandle ; usually an empty handle Size theSize ; desired amount of memory for the block specified number of bytes as a relocatable memory block. This is normally
used to get some memory before regenerating the data of a handle that has been
purged.
theHandle is normally an empty handle (a handle pointing to a NIL master
pointer); e.g. a handle that was tagged as purgeable and did, in fact,
get purged. If theHandle is non-empty, its data area is released
before a new area is allocated.
theSize is the desired logical size to be allocated. This must be less than
16M (a 24-bit value).
memFullErr (-108) No room in heap
memWZErr (-111) Illegal operation on a free block
memPurErr (-112) Illegal operation on a locked block
Notes: When it is allocated, a relocatable block is tagged as unpurgeable but a
subsequent call to HPurge will let the block's data be discarded in the event of a memory shortage. In that case, theHandle 's master pointer is set to NIL
and its data is lost.
Note: After being purged, theHandle continues to point to a valid (though NIL) master pointer, unlike the effect of DisposHandle, which discards the master pointer.
When working with purgeable blocks, you must ALWAYS check that the
relevant handle is not empty before assuming its data is available. e.g.,
HPurge( myHandle ); [TOKEN:12074] allow purging */ .
:
if ( *myHandle == 0) {
... can't get any memory, crash now ...
}
... regenerate data, read a file, etc ...
}
... now access the data as if nothing happened ...
Before purging any blocks, the Memory Manager will first attempt to grow
the heap, then it will compact the heap. It will also call your custom heap
After being re allocated, the handle is initially marked as unpurgeable and
you must call HPurge explicitly to make it purgeable again. A locked block will never be purged (see HLock).