Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-09

Nil'ing a dynamic string array...

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Torsten Bonde Christiansen

Hi.

A short question: Will nil'ing a dynamic string array automatically decrease ref. count on all strings in the array or must this be done manually for the entire array?

Eg.:
var
  StrArray: array of string;
StrArray := nil;

vs.

for i := 0 to High(strarray) do
  StrArray[i] := nil;

Kind regards,
Torsten Bonde Christiansen.

Jonas Maebe
to Torsten Bonde Christiansen
Torsten Bonde Christiansen wrote
A short question: Will nil'ing a dynamic string array automatically decrease ref. count on all strings in the array or must this be done manually for the entire array?

When a dynamic array is finalised (this happens when you assign nil to it), its contents are also finalised. So no, you don't have to manually finalise the individual strings in the array.

Jonas