ReAllocateMemory()
Syntax
*MemoryID = ReAllocateMemory(*MemoryID, Size)Description
Allocates (when parameter *MemoryID is 0) a new or re-allocates (with a valid *MemoryID as parameter) an existing contiguous memory area according to the specified size (in bytes). If the needed memory is available, the return value *MemoryID will get the start address of the memory area, else it will be 0 (the existing memory area will remain then, as well its previous *MemoryID stay valid).
The content of the previous memory area '*MemoryID' is kept. If the new 'size' of the memory area is smaller than the previous one, the end is cutted. If the new 'size' is larger than the previous one, the memory area will be filled up with Null.
Note: All the allocated memory areas are automatically freed when the programs ends.
Example:*MemoryID = AllocateMemory(1000) PokeS(*MemoryID, "Store this string") ; do something more with it here... ; *NewMemoryID = ReAllocateMemory(*MemoryID, 2000) ; need more memory If *NewMemoryID ; work with *NewMemoryID now with size 2000 Debug "The old contents are still here:" Debug PeekS(*NewMemoryID) ; FreeMemory(*NewMemoryID) Else ; resizing failed, keep working with *MemoryID (size 1000) ; FreeMemory(*MemoryID) EndIf
Supported OS
All