core: convert filter_constraint_data_to_string to C++

Return an std::string to avoid memory management headaches.

While doing that, convert time.c to C++ so that
format_datetime directly returns an std::string.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-02-29 11:31:46 +01:00 committed by Michael Keller
parent 898ecd2df5
commit 2e1d852e36
8 changed files with 29 additions and 32 deletions

View file

@ -657,7 +657,6 @@ static void save_filter_presets(struct membuffer *b)
free(fulltext);
for (int j = 0; j < filter_preset_constraint_count(i); j++) {
char *data;
const struct filter_constraint *constraint = filter_preset_constraint(i, j);
const char *type = filter_constraint_type_to_string(constraint->type);
put_format(b, " <constraint");
@ -673,9 +672,8 @@ static void save_filter_presets(struct membuffer *b)
if (constraint->negate)
put_format(b, " negate='1'");
put_format(b, ">");
data = filter_constraint_data_to_string(constraint);
show_utf8(b, data, "", "", 0);
free(data);
std::string data = filter_constraint_data_to_string(constraint);
show_utf8(b, data.c_str(), "", "", 0);
put_format(b, "</constraint>\n");
}
put_format(b, " </filterpreset>\n");