TMemoryStream is backed only by a single block of memory (accessible via the aptly named
Memory property), meaning that you can just call
FillChar / FillQWord / ZeroMemory et al. on that block. You don't even need to reset the position since
Memory always refers to the start of the block:
procedure ZeroStream(Stream: TMemoryStream);
begin
FillChar(Stream.Memory^, Stream.Size, 0);
end;
P.S.: You don't need to pass class instances as
var in most cases; even with
const class members may still be modified.
Class instances are essentially pointers, and class types don't get special treatment for
var / out / const / constref; these specifiers still refer to the
pointer value of a class instance and
not the
instance data.
Just FYI
