[Overview][Constants][Types][Classes][Procedures and functions][Variables] Reference for unit 'System' (#rtl)

ReAllocMem

Re-allocate memory on the heap

Declaration

Source position: heaph.inc line 99

function ReAllocMem(

  var p: pointer;

  Size: PtrInt

):pointer;

Description

ReAllocMem resizes the memory pointed to by P so it has size Size. The value of P may change during this operation. The contents of the memory pointed to by P (if any) will be copied to the new location, but may be truncated if the newly allocated memory block is smaller in size. If a larger block is allocated, only the used memory is initialized, extra memory will not be zeroed out.

Note that P may be nil, in that case the behaviour of ReAllocMem is equivalent to Getmem.

See also

GetMem

  

Allocate new memory on the heap

FreeMem

  

Release allocated memory

Zeroing of memory

It should be noted that as of FPC 2.1.1 rev6824, ReallocMem doesn't zero allocated memory (like Delphi does).

-- Unregistered Visitor on March 14, 2007 12:10 PM (view details)

RE: Zeronig of memory

Scrap that. I've just checked Delphi docs and it states that contents of newly-allocated memory are undefined.
-etrusco

(PS. I am the author of the previous comment.)

-- Unregistered Visitor on March 21, 2007 01:43 AM (view details)