[fpc-pascal] freeing string equal to setting to empty string?
Marc Santhoff
M.Santhoff at t-online.de
Thu Jul 24 04:42:12 CEST 2008
Am Mittwoch, den 23.07.2008, 19:21 +0200 schrieb Luca Olivetti:
> El Wed, 23 Jul 2008 17:15:13 +0200
> Marc Santhoff <M.Santhoff at t-online.de> escribió:
>
> > That's the important part, I'm dealing with cleanly freeing strings
> > when destroying objects.
>
> I may be wrong but I think you don't need to do anything, when you free
> a class the memory used by string fields is automagically freed
> (either that or heaptrc is lying[*] when it says my programs aren't
> leaking memory)
So as a rule of thumb strings can be used like any other non-object and
non-heap variable, as long as they are declared in the context of a
class.
If other objects or vars are holding pointers, ref counting prevents
freeing strings still needed.
Marc
More information about the fpc-pascal
mailing list