LorenPechtel
Programmer
Situation:
Procedure ZeroLargeRecord(var Data : tLargeRecord);
// tLargeRecord contains a lot of integers and one dynamic array
Var Temp : tLargeRecord;
Begin
Move(Data, Temp, SizeOf(Data)); // Save a copy of the dynamic array pointer
FillChar(Data, SizeOf(Data), 0); // Works as expected
Move(Temp.Dynamic, Data.Dynamic, SizeOf(Temp.Dynamic));
// This correctly restores the pointer. However, the compiler is figuring out that I'm messing with a dynamic array and it's inserting a call to finalizerecord. I've also tried:
Move(LongInt(Temp.Dynamic), LongInt(Data.Dynamic)...
// but it still is catching on.
Obviously I could set the length of the array to zero before doing this but that means reallocating the memory and this is a routine that gets called often but the size of the array very rarely changes.
Procedure ZeroLargeRecord(var Data : tLargeRecord);
// tLargeRecord contains a lot of integers and one dynamic array
Var Temp : tLargeRecord;
Begin
Move(Data, Temp, SizeOf(Data)); // Save a copy of the dynamic array pointer
FillChar(Data, SizeOf(Data), 0); // Works as expected
Move(Temp.Dynamic, Data.Dynamic, SizeOf(Temp.Dynamic));
// This correctly restores the pointer. However, the compiler is figuring out that I'm messing with a dynamic array and it's inserting a call to finalizerecord. I've also tried:
Move(LongInt(Temp.Dynamic), LongInt(Data.Dynamic)...
// but it still is catching on.
Obviously I could set the length of the array to zero before doing this but that means reallocating the memory and this is a routine that gets called often but the size of the array very rarely changes.