[fpc-pascal] cloning data containers

Marc Santhoff M.Santhoff at web.de
Sun Dec 28 02:19:25 CET 2014


On So, 2014-12-28 at 00:01 +0100, Sven Barth wrote:
> Am 27.12.2014 16:11 schrieb "Marc Santhoff" <M.Santhoff at web.de>:
> > Is there any way of cloning record and objects having only data fields?
> > Or do I have to copy the (non reference) fields one by one as usual?
> 
> Shouldn't the normal assignment be enough for any non-reference (aka
> non-managed pointers) fields?

In principle you are right, maybe too simple for me. ;)

To be serious I remember some problems in the past, IIRC there were
strings involved, which are in fact pointers under the surface. I'll
check that, having to dig deep ...

> Meaning first you simply assign your input record to the result (strings,
> arrays and interfaces will be handled here) and then you update those
> fields that should be "deep copied".

Should do.

-- 
Marc Santhoff <M.Santhoff at web.de>




More information about the fpc-pascal mailing list