function ReallocMemory(P: Pointer; Size: NativeInt): Pointer; cdecl;
extern DELPHI_PACKAGE void * __cdecl ReallocMemory(void * P, NativeInt Size);
ReallocMemory resizes a memory block.
GetMem allocates a block of the given Size on the heap. If you have to change the size of this memory block, call ReallocMemory, passing the existing memory block pointer in P, and the revised block size in Size. A pointer to the resized memory block is returned. If ReallocMemory cannot expand the memory block pointed to by P, it frees the referenced memory and copies the values to the newly allocated memory that is returned.
If there is not enough memory available to extend the memory block to the desired size, an EOutOfMemory exception is raised.