mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: replace divesite_table_t by a vector of std::unique_ptr<>s
This is a long commit, because it introduces a new abstraction: a general std::vector<> of std::unique_ptrs<>. Moreover, it replaces a number of pointers by C++ references, when the callee does not suppoert null objects. This simplifies memory management and makes ownership more explicit. It is a proof-of-concept and a test-bed for the other core data structrures. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
411188728d
commit
e39dea3d68
41 changed files with 451 additions and 426 deletions
|
@ -915,7 +915,7 @@ static bool process_raw_buffer(device_data_t *devdata, uint32_t deviceid, std::s
|
|||
} else if (!is_log && dive && tag == "divespot_id") {
|
||||
int divespot_id;
|
||||
if (from_chars(val, divespot_id).ec != std::errc::invalid_argument) {
|
||||
struct dive_site *ds = create_dive_site("from Uemis"s, devdata->log->sites);
|
||||
struct dive_site *ds = create_dive_site("from Uemis"s, *devdata->log->sites);
|
||||
unregister_dive_from_dive_site(dive);
|
||||
add_dive_to_dive_site(dive, ds);
|
||||
uemis_obj.mark_divelocation(dive->dc.diveid, divespot_id, ds);
|
||||
|
@ -1109,21 +1109,20 @@ static void get_uemis_divespot(device_data_t *devdata, const std::string &mountp
|
|||
* we search all existing divesites if we have one with the same name already. The function
|
||||
* returns the first found which is luckily not the newly created.
|
||||
*/
|
||||
struct dive_site *ods = get_dive_site_by_name(nds->name, devdata->log->sites);
|
||||
if (ods) {
|
||||
struct dive_site *ods = get_dive_site_by_name(nds->name, *devdata->log->sites);
|
||||
if (ods && nds->uuid != ods->uuid) {
|
||||
/* if the uuid's are the same, the new site is a duplicate and can be deleted */
|
||||
if (nds->uuid != ods->uuid) {
|
||||
delete_dive_site(nds, devdata->log->sites);
|
||||
unregister_dive_from_dive_site(dive);
|
||||
add_dive_to_dive_site(dive, ods);
|
||||
}
|
||||
unregister_dive_from_dive_site(dive);
|
||||
add_dive_to_dive_site(dive, ods);
|
||||
devdata->log->sites->pull(nds);
|
||||
}
|
||||
divespot_mapping[divespot_id] = dive->dive_site;
|
||||
} else {
|
||||
/* if we can't load the dive site details, delete the site we
|
||||
* created in process_raw_buffer
|
||||
*/
|
||||
delete_dive_site(dive->dive_site, devdata->log->sites);
|
||||
devdata->log->sites->pull(dive->dive_site);
|
||||
dive->dive_site = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue