[Libreoffice] [PATCH] convert SdCustomShow from tools/list to vector

Eike Rathke erack at redhat.com
Fri Jan 27 07:46:13 PST 2012


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20120127/0a0c2e92/attachment.pgp>


More information about the LibreOffice mailing list