core: port filterpreset.cpp to std::string

Less memory management hassle.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-02-29 13:39:17 +01:00
parent 5d36ba4593
commit 68ddce5b11
11 changed files with 44 additions and 57 deletions

View file

@ -984,18 +984,14 @@ static void format_one_filter_constraint(int preset_id, int constraint_id, struc
*/
static void format_one_filter_preset(int preset_id, struct membuffer *b)
{
char *name, *fulltext;
std::string name = filter_preset_name(preset_id);
show_utf8(b, "name ", name.c_str(), "\n");
name = filter_preset_name(preset_id);
show_utf8(b, "name ", name, "\n");
free(name);
fulltext = filter_preset_fulltext_query(preset_id);
if (!empty_string(fulltext)) {
std::string fulltext = filter_preset_fulltext_query(preset_id);
if (!fulltext.empty()) {
show_utf8(b, "fulltext mode=", filter_preset_fulltext_mode(preset_id), "");
show_utf8(b, " query=", fulltext, "\n");
show_utf8(b, " query=", fulltext.c_str(), "\n");
}
free(fulltext);
for (int i = 0; i < filter_preset_constraint_count(preset_id); i++)
format_one_filter_constraint(preset_id, i, b);