diff --git a/src/spellchecker_hunspell.cpp b/src/spellchecker_hunspell.cpp index 9ccc6a520e..96edb3d7a0 100644 --- a/src/spellchecker_hunspell.cpp +++ b/src/spellchecker_hunspell.cpp @@ -117,7 +117,7 @@ void HunspellSpellChecker::WriteUserDictionary() { bool HunspellSpellChecker::CheckWord(std::string_view word) { if (!hunspell) return true; try { - return hunspell->spell(conv->Convert(word).c_str()) == 1; + return hunspell->spell(conv->Convert(word)) == 1; } catch (agi::charset::ConvError const&) { return false; @@ -128,23 +128,18 @@ std::vector HunspellSpellChecker::GetSuggestions(std::string_view w std::vector suggestions; if (!hunspell) return suggestions; - char **results; - int n = hunspell->suggest(&results, conv->Convert(word).c_str()); + std::vector results = hunspell->suggest(conv->Convert(word)); - suggestions.reserve(n); // Convert suggestions to UTF-8 - for (int i = 0; i < n; ++i) { + for (auto const& result : results) { try { - suggestions.push_back(rconv->Convert(results[i])); + suggestions.push_back(rconv->Convert(result)); } catch (agi::charset::ConvError const&) { // Shouldn't ever actually happen... } - free(results[i]); } - free(results); - return suggestions; }