On Tue, 6 Jun 2006, David Nicolás Abdala wrote:


Since the fpc list is down, I post my message here...


---------- Forwarded message ----------
From: Alexandre Leclerc <[EMAIL PROTECTED]>
Date: 05.06.2006 17:27
Subject: Question about memory leaks with array of string
To: FPC-Pascal users discussions <[email protected]>


I made the following dynamic array: a: array of string.

I do SetLength(a, 10) then assign values. In order to prevent memory
leaks, does a simple SetLength(a, 0) will do the job, or do I have to
also SetLength(a[n], 0) of all the values?

This is not necessary. This is all handled automatically for you.
Just do the setlength:
SetLength(a, 10);

The compiler does the rest.

Michael.

Reply via email to