On Saturday, November 16, 2013, at 02:36 Martin wrote: > On 16/11/2013 01:03, Timothy Groves wrote: >> >> Here's the code I *actually* have in the method: >> >> var >> index, >> last : integer; >> begin >> last := length (t_volumes) - 1; >> index := 0; >> while ((t_volumes [index] <> t_current_volume) and (index < last)) do >> inc (index); >> if (index < last) then begin >> t_volumes [index] := t_volumes [last]; > Objects are actually stored via a reference (internal pointer) > So t_volumes [last] just points to the objects data > > The above statement duplicates the reference > >> t_volumes [last].Destroy; > > destroys the object pointed to by both: t_volumes [last] and t_volumes > [index] > > You should have destroyed t_volumes [index] *before* copying the value
Maybe a bit late, but that might not be true. If Timothy really talks about _object_ (and not _class(TObject)_) it should work as he does it. Also Destroy would probably be appropriate. Just saying :-) The actual type defs used are missing. -- Best Regards, Andreas _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal