Hi Kohei,

On Friday, 2012-01-27 09:53:50 -0500, Kohei Yoshida wrote:

> 4) Last point.  List takes ownership of the contained objects, which
> means it automatically deletes those objects when destroyed.  When you
> use vector, that convenience is gone, so you'll need to manually delete
> the contained objects.  Or, in this case it's probably better to use
> ptr_vector instead.

Actually no, List does not take ownership of objects and does not delete
upon destruction! Ownership is only with SV_DECL_PTRARR_DEL and
SV_DECL_PTRARR_SORT_DEL

5) One caveat: List::Next() (and in general Next() of Container derived
   classes) return NULL if invoked on the last element. Care has to be
   taken when replacing
   for (p = list.First(); p; p = list.Next())
   with
   for (it = list.begin(); it != list.end(); ++it)
   If p is accessed after the loop it was NULL after the last element if
   the loop didn't break before, but from the last valid iterator (p=*it
   or some such) it will be non-NULL instead, the pointer of the last
   element. In such cases p needs to get explicitly assigned NULL if
   list reached end.


  Eike

-- 
LibreOffice Calc developer. Number formatter stricken i18n transpositionizer.
GnuPG key 0x293C05FD : 997A 4C60 CE41 0149 0DB3  9E96 2F1A D073 293C 05FD

Attachment: pgpEKYaqHfoct.pgp
Description: PGP signature

_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Reply via email to