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

New

Dynamically allocate memory for variable

Declaration

Source position: system.fpd line 50

procedure New(

  var P: Pointer

);

procedure New(

  var P: Pointer;

  Cons: TProcedure

);

Description

New allocates a new instance of the type pointed to by P, and puts the address in P. If P is an object, then it is possible to specify the name of the constructor with which the instance will be created.

The newly allocated memory is not initialized in any way, and may contain garbage data. It must be cleared with a call to FillChar or FillWord.

For an example, see Dispose.

Errors

What happens if no more memory is available, depends on the value of the variable ReturnNilIfGrowHeapfails: if the variable is True then Nil is returned. If the variable is False, a run-time error is generated.

See also

Dispose

  

Free dynamically allocated memory

Freemem

  

Release allocated memory

Getmem

  

Allocate new memory on the heap

ReturnNilIfGrowHeapfails

  

Describe behaviour if getmem fails.


Documentation generated on: Mar 17 2017