[fpc-pascal] memory management with open arrays and classes
David Emerson
dle3ab at angelbase.com
Thu Jun 26 17:33:08 CEST 2008
Thanks, Joost, for all of your answers! It looks like I need to write
*more* cleanup code, and double-check it all.
One question remains:
> After calling setlength, the items in the array are not initialised.
>
> [...]
>
> Initialising the strings you can do by setting them to an empty
> string. (s := '')
I had the impression that an ansistring is essentially a special kind of
pointer. Since the *pointer* contains random (not nil) data, then ...
if I assign it to empty-string, wouldn't fpc treat the old random
pointer reference as an ansistring that needs to have its reference
count decremented?
For this reason, I have previously used fillchar to nil those out.
Thanks,
David
More information about the fpc-pascal
mailing list