----boundary-LibPST-iamunique-1463119870_-_-
Content-type: text/plain
> -----Original Message-----
> From: Hof, Philipp [mailto:p.hof{([at]})nowhere.xy> Sent: Friday, 1 October 2004 12:50 PM
> To: 'blackbox{([at]})nowhere.xy> Subject: clear or fill memory?
>
>
> Thanks for your replies:)
>
> Leading to my next question:
> Is there a built-in function to zero (or fill) everything in
> a RECORD? I could use RtlZeroMemory from the Windows API but
> rather would not.
>
I would always prefer to see record fields clearly and explicity
assigned, rather than having to
a) guess what the programmer intended (boolean values?)
b) wonder whether he had overlooked anything
If record fields are not pre-initialised, it is more likely that any
subsequent oversight will result in unexpected behaviour and give you an
early opportunity to identify what had been forgotten.
However, having said that, if you do have a compelling reason to preset
a record, noting that:
1. Global variables ARE initialised in Component Pascal
2. An entire record structure can be assigned in a single assignment
statement
it is possible to declare a global variable of the same record type and
then assign that to initialise an entire record in a procedure.
e.g.
TYPE
SomeRecord = RECORD
a: ARRAY 3 OF BOOLEAN;
r: REAL;
i: INTEGER;
r1: AnotherRecordType;
...
...
END;
VAR
someRecordInitialised: SomeRecord;
PROCEDURE SomeProcedure;
VAR
sr: SomeRecord;
BEGIN
sr := someRecordInitialised;
...
...
...
The obvious risk with this technique, is that there is nothing to
prevent 'someRecordInitialised' from being accidentally modified.
Chris Burrows
CFB Software
http://www.cfbsoftware.com
--------------------------------------------
To unsubscribe from this mailing list, send a message containing the word "unsubscribe" to:
blackbox-request{([at]})nowhere.xy
To get a list of valid e-mail commands and instructions on their usage, send a message containing the word "help" to the above address.
Send any problem reports or questions related to this email list to the list owner at
owner-blackbox{([at]})nowhere.xy
Current posting policy:
a) To post you should use the same address by which you are subscribed to the mailing list. That way, the list server will recognize you as subscriber and forward your posting immediately, without creating any overhead.
b) If, for some reason, you cannot post from the address, by which you are subscribed, your message will be moderated to avoid spam. Please understand that moderation will often cause some delay, in particular over weekends or holydays.
----boundary-LibPST-iamunique-1463119870_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="r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