| HeapRealloc | Function (ROM Call 0x9D)

alloc.h

HANDLE HeapRealloc (HANDLE Handle, unsigned long NewSize);

Reallocates a block to a new size.

If Handle is H_NULL, HeapRealloc calls HeapAlloc. Otherwise, it tries to reallocate the given heap block to a new size. Returns H_NULL if there is not enough memory (it will try to call HeapCompress) or if new size is invalid; otherwise returns Handle (but Handle will still be valid even if there was not enough memory). If the heap block is locked, then the block will not be moved in order to reallocate it. However, unlocked blocks above the heap block will be moved. 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 block is indeterminate. This routine may cause garbage collection.
Note: Reallocating a locked block may fail very easily, especially if you have allocated and locked some blocks just shortly before. The reason is simple: If you allocate memory blocks in sequence, they are usually located close to each other. If you try to grow a locked block which lies directly in front of another locked block, the operation will fail because the second locked block cannot be moved. In general it is a good idea to unlock memory blocks before using HeapRealloc, and to lock them again afterwards if necessary. This way the probability to succeed is much higher.

Uses: HeapAlloc, HeapCompress, memmove, NeedStack
Used by: HeapReallocThrow, realloc, cmd_blddata, cmd_cubicreg, cmd_dialog, cmd_expreg, cmd_linreg, cmd_lnreg, cmd_logistic, cmd_medmed, cmd_newdata, cmd_onevar, cmd_powerreg, cmd_quadreg, cmd_quartreg, cmd_request, cmd_twovar, DialogAdd, check_estack_size, display_statements, index_below_display_expression_aux, Parse1DExpr, reset_estack_size, FClose, FPutC, HomeExecute, LIO_Receive, DynMenuAdd, DynMenuChange, fclose, fputc, CB_replaceTEXT, TE_checkSlack, TE_handleEvent, TE_pasteText, TE_shrinkWrap, convert_to_TI_92, delete_list_element, hStrAppend, OO_SetAttr, PlotDel, PlotPut, ReallocExprStruct, spike_geo_titles, spike_in_editor, spike_optionD, tokenize_if_TI_92_or_text, AddSymToFolder, FolderAdd, FolderDel, FolderRename, HSymDel, SymAddTwin, SymDel, SymDelTwin, VarStore, WinReOpen, ROM Call 0x439, ROM Call 0x4CB