mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
divelog: turn owning-pointers into unique_ptr<>s
Since everything is C++ now, we can use unique_ptr<>s. This makes the code significantly shorter, because we can now use the default move constructor and assignment operators. This has a semantic change when std::move()-ing the divelog: now not the contents of the tables are moved, but the pointers. That is, the moved-from object now has no more tables and must not be used anymore. This made it necessary to replace std::move()s by std::swap()s. In that regard, the old code was in principle broken: it used moved-from objects, which may work but usually doesn't. This commit adds a myriad of .get() function calls where the code expects a C-style pointer. The plan is to remove virtually all of them, when we move free-standing functions into the class it acts on. Or, replace C-style pointers by references where we don't support NULL. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
6e352d5281
commit
d242198c99
22 changed files with 113 additions and 138 deletions
|
@ -686,8 +686,8 @@ static void save_dives_buffer(struct membuffer *b, bool select_only, bool anonym
|
|||
put_format(b, "<divelog program='subsurface' version='%d'>\n<settings>\n", DATAFORMAT_VERSION);
|
||||
|
||||
/* save the dive computer nicknames, if any */
|
||||
for (int i = 0; i < nr_devices(divelog.devices); i++) {
|
||||
const struct device *d = get_device(divelog.devices, i);
|
||||
for (int i = 0; i < nr_devices(divelog.devices.get()); i++) {
|
||||
const struct device *d = get_device(divelog.devices.get(), i);
|
||||
if (!select_only || device_used_by_selected_dive(d))
|
||||
save_one_device(b, d);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue