diff --git a/native_client/ctcdecode/ctc_beam_search_decoder.cpp b/native_client/ctcdecode/ctc_beam_search_decoder.cpp index f6ec3082e3..64d0e33843 100644 --- a/native_client/ctcdecode/ctc_beam_search_decoder.cpp +++ b/native_client/ctcdecode/ctc_beam_search_decoder.cpp @@ -37,7 +37,8 @@ DecoderState::init(const Alphabet& alphabet, prefixes_.push_back(root); if (ext_scorer != nullptr && !ext_scorer->is_character_based()) { - auto dict_ptr = ext_scorer->dictionary->Copy(true); + // no need for std::make_shared<>() since Copy() does 'new' behind the doors + auto dict_ptr = std::shared_ptr(ext_scorer->dictionary->Copy(true)); root->set_dictionary(dict_ptr); auto matcher = std::make_shared>(*dict_ptr, fst::MATCH_INPUT); root->set_matcher(matcher); diff --git a/native_client/ctcdecode/path_trie.cpp b/native_client/ctcdecode/path_trie.cpp index 51f75ff39b..c1ad2441ec 100644 --- a/native_client/ctcdecode/path_trie.cpp +++ b/native_client/ctcdecode/path_trie.cpp @@ -165,9 +165,9 @@ void PathTrie::remove() { } } -void PathTrie::set_dictionary(PathTrie::FstType* dictionary) { +void PathTrie::set_dictionary(std::shared_ptr dictionary) { dictionary_ = dictionary; - dictionary_state_ = dictionary->Start(); + dictionary_state_ = dictionary_->Start(); has_dictionary_ = true; } @@ -201,4 +201,4 @@ void PathTrie::print(const Alphabet& a) { printf("\n"); printf("transcript:\t %s\n", tr.c_str()); } -#endif // DEBUG \ No newline at end of file +#endif // DEBUG diff --git a/native_client/ctcdecode/path_trie.h b/native_client/ctcdecode/path_trie.h index 9b71f35b1d..04cbfdd57a 100644 --- a/native_client/ctcdecode/path_trie.h +++ b/native_client/ctcdecode/path_trie.h @@ -39,7 +39,7 @@ class PathTrie { void iterate_to_vec(std::vector& output); // set dictionary for FST - void set_dictionary(FstType* dictionary); + void set_dictionary(std::shared_ptr dictionary); void set_matcher(std::shared_ptr>); @@ -72,7 +72,7 @@ class PathTrie { std::vector> children_; // pointer to dictionary of FST - FstType* dictionary_; + std::shared_ptr dictionary_; FstType::StateId dictionary_state_; // true if finding ars in FST std::shared_ptr> matcher_;