[fpc-pascal] readonly variables
Mehmet Erol Sanliturk
sanliturk at ttmail.com
Sun Nov 29 21:28:49 CET 2009
Jonas Maebe wrote:
> On 29 Nov 2009, at 19:20, Mehmet Erol Sanliturk wrote:
>
>> My experience with Windows XP Professional is that it is NOT zeroing the memory .
I know this from actual Delphi ( and also Free Pascal ) compiled program
executions .
Due to this I am explicitly initializing all of the local simple
variables ,
elements of records .
>
> The discussion was about global variables, not about local variables.
Local variables are indeed not initialised (not in FPC nor in Delphi/TP).
>
>
> Jonas
Dear Jonas ,
I am sorry about my misunderstanding .
We may think the global variables are placed in memory which is not
cleaned by operating system before starting the program . Therefore it
is necessary to initialize them . In a FreeBSD mailing list thread this
point is discussed about security vulnerability by complaining about a
package that it was not cleaning its global/local variables before
terminating and leaving values of them in memory ( this shows that
FreeBSD is NOT clearing memory itself running that package ) .
My habit is nearly in all of my programming life ( even in BASIC ) to
initialize all of the variables by myself . Now , I am removing almost
ALL of the global variables by making them local to starting procedures
. If I can not do that , nearly ALL of my global variables are placed
into RECORD declarations to prevent accidental effects of local variable
declarations with the same name hiding the global variable ( therefore
causing nearly impossible to find bugs ) .
This shows reason of my misunderstanding because for me there is no such
an initialization by compilers concept .
Thank you very much .
Mehmet Erol Sanliturk
More information about the fpc-pascal
mailing list