Hey,
so while looking through some of the current calc memory leaks I noticed
that at least some of them are related to our poor API and I noticed that
quite a few of the problems can easily be avoided with better API design.
For now I would like to propose that we try to use std::unique_ptr in two
places to show ownership of data. A method that returns an object for which
ownership transfers to the caller we should return the object wrapped in a
std::unique_ptr. The same should be done for a method taking ownership of a
pointer.
I hope that these are not really controversial and I'm aware that they are
not yet useful for all the old code but we need to start somewhere. Also if
there is some agreement on this there are some simple easy hacks that can
be done to move at least a bit of our code into this direction (e.g. the
horrible SfxItemPool::Clone method that results in quite a few of my leaks.)
Regards,
Markus
Context
- Proposal for using std::unique_ptr to signal transfer of ownership · Markus Mohrhard
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.