Marc Santhoff wroteThat's interesting and nice. Can I assume the same is valid for dyn
arrays in a procedure or function context?
The short answer is yes.
There was recently (about a month ago) a discussion about some of these very issues, from 21 to 29 June. I'd encourage you to read it.
(Unfortunately I erroneously made the subject line "memory management with open arrays and classes"; and I replied to another thread instead of starting a new thread, so the messages don't appear in a nice little self-contained thread. doh!)
...and three messages following; make sure you read the one by Jonas, as the first reply contains some misinformation.
~David.
Show quoted text 15 lines
Normal vars do "behave" that way ...
program x;
procedure a;
var
s: array of string;
begin
SetLength(s, count);
s[0] := 'a string';
... do something ...
end; { no freeing of the array strings needed? }
Indeed not. Even if s was an array of ansistrings, they would still be cleaned up automatically when the var goes out of scope.
Marc