fulltext: replace plain pointer by std::unique_ptr<>

This was a plain pointer owing to C compatibility.

Replacing it by a unique_ptr<> allows us to make it
'self-desctruct' in the constructor. However, we do this
with a special twist: the data is _not_ copied when copying
the dive, since the copied dive is not registered in the fulltext
system. Hackish, but it should(!) work.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-06-03 19:09:43 +02:00 committed by bstoeger
parent 5c7cfb1057
commit c9d4ce0c15
4 changed files with 25 additions and 26 deletions

View file

@ -49,13 +49,9 @@ dive::dive() : dcs(1)
id = dive_getUniqID();
}
dive::~dive()
{
fulltext_unregister(this); // TODO: this is a layering violation. Remove.
}
dive::dive(dive &&) = default;
dive &dive::operator=(const dive &) = default;
dive::~dive() = default;
/*
* The legacy format for sample pressures has a single pressure
@ -180,9 +176,7 @@ void clear_dive(struct dive *d)
void copy_dive(const struct dive *s, struct dive *d)
{
/* simply copy things over, but then clear fulltext cache and dive cache. */
fulltext_unregister(d);
*d = *s;
d->full_text = NULL;
invalidate_dive_cache(d);
}