RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
System.TMemoryManager Record

TMemoryManager defines the memory block entry points.

Pascal
TMemoryManager = record
  GetMem: function(Size: Integer): Pointer;
  FreeMem: function(P: Pointer): Integer;
  ReallocMem: function(P: Pointer; Size: Integer): Pointer;
end;
C++
struct TMemoryManager {
  function(Size: Integer): Pointer GetMem;
  function(P: Pointer): Integer FreeMem;
  function(P: Pointer; Size: Integer): Pointer ReallocMem;
};

System

The TMemoryManager type is used by the GetMemoryManager and SetMemoryManager procedures. It defines the routines that allocate and free memory.  

The GetMem field (Delphi) or method (C++) must specify a function that allocates the given number of bytes and returns a pointer to the newly allocated block, as invoked by the GetMemory routine.  

The Size parameter passed to the GetMem function will never be zero. If the GetMem function cannot allocate a block of the given size, it should return nil (Delphi) or NULL (C++).  

The FreeMem field (Delphi) or method (C++) must specify a function that deallocates the given block. The pointer parameter passed to the FreeMem function will never be nil (Delphi) or NULL (C++). If the FreeMem function successfully deallocates the given block, it should return zero. Otherwise, it should return a non-zero value. As invoked by the FreeMemory routine.  

The ReallocMem field (Delphi) or method (C++) must specify a function that reallocates the given block to the given new size. The pointer parameter passed to the ReallocMem function will never be nil (Delphi) or NULL (C++), and the Size parameter will never be zero. The ReallocMem function must reallocate the given block to the given new size, possibly moving the block if it cannot be resized in place. Any existing contents of the block must be preserved, but newly allocated space can be uninitialized. The ReallocMem function must return a pointer to the reallocated block, or nil (Delphi) or NULL (C++) if the block cannot be reallocated. As invoked by the ReallocMem routine. 

 

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