BaseAddress is a public uint64, in fact seeing the code it seems to me that it is useless.
And hopefully so is "Data" otherwise that code leaks the entire array memory block. ("Data" has to eventually be freed somewhere which means it has to be accessible to the method that is responsible for freeing it.)
In the code that @Zvoni gave you, "Data" is a local variable but, in _your_ code, "Data" cannot be local to the method (otherwise its value is lost and, as a result, there is no way to free the block it points to.)
Correct.
In a nutshell, i translated the C#-code as close as possible to be „literally“ the same.
Yes, i used Data as a local var (to be able to compile), but my guess is, that that procedure is a member of a class (and „this.BaseAddress“ is a strong hint), and Data is actually a Property of the class.
After i figured out, what the function is actually doing, i wrote my „conclusion below (the bit with FillChar).
Wouldn’t surprise me, if FPC has a ready-made function for that
And people laugh at me when i call it Dot CRAP…..