On Thu, Sep 30, 2010 at 02:19:03PM +0900, Seo Sanghyeon wrote:
Attached patch removes DynamicList and migrate its users from
DynamicList<T> to std::vector<T *>.
<vector> header is included. "list.hxx" is not removed because it is
still used for List class.
Hi,
std::vector<T*> is not a correct replacement for DynamicList<T>, because
the latter manages the lifetime of its members, which std::vector does
not do, therefore every remove causes a memory leak. std::vector (or,
maybe, std::deque) is a suitable replacement for List. For DynamicList,
you have basically the following options:
1. track all removals from any DynamicList (including destructions)
and add explicit delete of affected items
2. revamp DynamicList into a wrapper over std::vector (std::deque),
that calls delete on the to-be-removed item(s) (so you'll end with
the same class we have now, just with different implementation...)
3. use boost::ptr_vector (or boost::ptr_deque) (this is what I'd use,
but others may be opposed to introducing a dependency on boost to
xml2cmp)
4. use std::vector<boost::shared_ptr<T> > (dep. on boost, again)
D.
Context
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.