<p>Am 21.02.2016 03:02 schrieb "Mazola Winstrol" <<a href="mailto:mazofeifer@gmail.com">mazofeifer@gmail.com</a>>:<br>
><br>
> 2016-02-20 3:24 GMT-02:00 Michalis Kamburelis <<a href="mailto:michalis.kambi@gmail.com">michalis.kambi@gmail.com</a>>:<br>
>><br>
>> The major problem there is that it's difficult to force it to be<br>
>> always initialized with zeroes. Currently, a non-global variable of<br>
>> unmanaged type can always be filled with memory garbage, as explained<br>
>> in other thread. The trick in<br>
>> <a href="http://blogs.embarcadero.com/abauer/2008/09/18/38869">http://blogs.embarcadero.com/abauer/2008/09/18/38869</a> to use interfaces<br>
>> feels ugly, it's an over-use of the "interface" specifics in Object<br>
>> Pascal.<br>
>><br>
><br>
> A less "ugly" code could be to store the pointer value in an array of bytes (TBytes). As the TBytes type is a managed type, it will always be initialized.</p>
<p>The managed type isn't needed for the data (that should be stored as a plain field to let the compiler take care of finalization), but instead it's needed to store whether the field contains a valid value (not Null) or not (null). For this potentially any managed type (array, string, interface) can be used, but it might indeed be that the manual interface approach is the fastest, because there one can avoid unnecessary locking (it's done by the implementations of AddRef and Release) which is not the case with arrays and strings as the reference counting routines always do locking.</p>
<p>Regards,<br>
Sven</p>