core: use C++-primitives for g_tag_list

The old code was leaking memory. Use std::unique_ptr<> for
ownership management.

This is still very primitive and divetags are kept during
application lifetime. There should probably be some form
of reference counting. And the taglist should not be global,
but attached to the divelog.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-03-26 21:06:13 +01:00 committed by bstoeger
parent b320942343
commit 556ecd5a9b
23 changed files with 92 additions and 125 deletions

View file

@ -387,10 +387,10 @@ static void save_tags(struct membuffer *b, struct tag_entry *entry)
if (entry) {
const char *sep = " tags='";
do {
struct divetag *tag = entry->tag;
const struct divetag *tag = entry->tag;
put_string(b, sep);
/* If the tag has been translated, write the source to the xml file */
quote(b, tag->source ?: tag->name, 1);
quote(b, tag->source.empty() ? tag->name.c_str() : tag->source.c_str(), 1);
sep = ", ";
} while ((entry = entry->next) != NULL);
put_string(b, "'");