mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: add constructor/destructor pairs to dive and divecomputer
This allows us to use non-C member variables. Convert a number of pointers to unique_ptr<>s. Code in uemis-downloader.cpp had to be refactored, because it mixed owning and non-owning pointers. Mad. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
bfb54aa581
commit
cc39f709ce
35 changed files with 289 additions and 308 deletions
|
@ -11,6 +11,15 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
divecomputer::divecomputer()
|
||||
{
|
||||
}
|
||||
|
||||
divecomputer::~divecomputer()
|
||||
{
|
||||
free_dc_contents(this);
|
||||
}
|
||||
|
||||
/*
|
||||
* Good fake dive profiles are hard.
|
||||
*
|
||||
|
@ -234,11 +243,15 @@ int get_depth_at_time(const struct divecomputer *dc, unsigned int time)
|
|||
}
|
||||
|
||||
|
||||
/* The first divecomputer is embedded in the dive structure. Free its data but not
|
||||
* the structure itself. For all remainding dcs in the list, free data *and* structures. */
|
||||
static void free_dc(struct divecomputer *dc)
|
||||
{
|
||||
delete dc;
|
||||
}
|
||||
|
||||
/* The first divecomputer is embedded in the dive structure. Ignore it.
|
||||
* For all remainding dcs in the list, free data and structures. */
|
||||
void free_dive_dcs(struct divecomputer *dc)
|
||||
{
|
||||
free_dc_contents(dc);
|
||||
STRUCTURED_LIST_FREE(struct divecomputer, dc->next, free_dc);
|
||||
}
|
||||
|
||||
|
@ -545,12 +558,6 @@ void free_dc_contents(struct divecomputer *dc)
|
|||
STRUCTURED_LIST_FREE(struct extra_data, dc->extra_data, free_extra_data);
|
||||
}
|
||||
|
||||
void free_dc(struct divecomputer *dc)
|
||||
{
|
||||
free_dc_contents(dc);
|
||||
free(dc);
|
||||
}
|
||||
|
||||
static const char *planner_dc_name = "planned dive";
|
||||
|
||||
bool is_dc_planner(const struct divecomputer *dc)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue