RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
System.ReallocMem Function

Reallocates a dynamic variable.

Pascal
procedure ReallocMem(var P: Pointer; Size: Integer);
C++
ReallocMem(void * P, int Size);

System

On entry, P must be nil or point to a dynamic variable that was previously allocated with GetMem, AllocMem, or ReallocMem. 

If P is nil and Size is zero, ReallocMem does nothing. 

If P is nil and Size is not zero, ReallocMem allocates a new block of the given size and sets P to point to the block. This corresponds to a call to GetMem

If P is not nil and Size is zero, ReallocMem disposes the block referenced by P and sets P to nil. This corresponds to a call to FreeMem, except that FreeMem doesn't clear the pointer. 

If P is not nil and Size is not zero, ReallocMem reallocates the block referenced by P to the size given by Size. Existing data in the block is not affected by the reallocation, but if the block is made larger, the contents of the newly allocated portion of the block are undefined. If the block cannot be reallocated in place, it is moved to a new location in the heap, and P is updated accordingly. 

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!