RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
System.Initialize Function

Initializes a dynamically allocated variable.

Pascal
procedure Initialize(var V); overload;
procedure Initialize(var V; Count: Integer); overload;
C++
Initialize( V);
Initialize( V, int Count);

System

Initialize should be used only in Delphi code where a variable is dynamically allocated by other means than the New standard procedure. 

For global variables, local variables, objects, and dynamic variables allocated using New, the compiler generates code that initializes all long strings and variants contained by a variable upon creation of the variable. A call to Initialize is required to initialize a variable before it can be used if:

  • the dynamic variable is created by other means than the New standard function (for example using GetMem or ReallocMem).
  • the variable contains long strings, variants, or interfaces.
  • the dynamic variable is created by other means than the New standard function (for example using GetMem or ReallocMem).
  • the variable contains long strings, variants, or interfaces.
  • the memory allocated for the variable is not initialized to zeros.

Initialize simply zeros out the memory occupied by long strings, variants, and interfaces, causing long strings to be empty and variants and interfaces to be Unassigned. 

In cases where several variables are allocated in a contiguous memory block, the additional Count parameter can be specified to initialize all variables in one operation. 

If the variable specified in a call to Initialize contains no long strings, variants, or interfaces, the compiler eliminates the call and generates no code for it. 

 

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