...
PAnalyzeInfo = ^TAnalyzeInfo;
TAnalyzeInfo = record
pPitch: array of Single;
pEnergy: array of Single;
pPitchAccent: array of Single;
pEnergyAccent: array of Single;
pDicAccent: array of Single;
pScore: array of Single;
pBoundary: Integer;
szRecWord: array of array of AnsiChar;
nRecWordNum: Integer;
nFrameNum: Integer;
end;
...
I have pDataSource: PAnalyzeInfo which contains data and I want to copy it to a new independent variable. MyData : TAnalyzeInfo.
Is it possible to copy the whole structure or adding it one bye one?
In Delphi you can copy a record just by assigning it, thanks to compiler magic.
MyData := DataSource^;
The dynamic arrays are reference counted, so the assignment also takes care of the dynamic arrays as long as you don't need a real deep copy. With a simple assignment they just share the same memory.
If you don't want that you can copy them individually:
MyData.pPitch = Copy(pDataSource^.pPitch, Low(pDataSource^.pPitch),
High(pDataSource^.pPitch);
No, the dynamic arrays cannot be copied with a single copy command. You will have to:
It would be much easier if the arrays were static. In that case copying the whole memory block would be possible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With