diff options
author | vng <viktor.govako@gmail.com> | 2012-09-06 16:24:25 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:43:10 +0300 |
commit | dd63cdd69f687b6e5e5557cbaf3a7d5036bdb820 (patch) | |
tree | 3ca83e88ecee00ff8d73a5f0896d72646a7b8a7a /search | |
parent | 799105a4f553f0d07720cbd0d8ac5f1b793e9a44 (diff) |
[search] Fix memory leaks.
Diffstat (limited to 'search')
-rw-r--r-- | search/feature_offset_match.hpp | 2 | ||||
-rw-r--r-- | search/search_query.cpp | 35 |
2 files changed, 16 insertions, 21 deletions
diff --git a/search/feature_offset_match.hpp b/search/feature_offset_match.hpp index c64a845d32..c6b87da0cc 100644 --- a/search/feature_offset_match.hpp +++ b/search/feature_offset_match.hpp @@ -57,7 +57,7 @@ TrieIterator * MoveTrieIteratorToString(TrieIterator const & trieRoot, if ((count > 0) && (count == szEdge || szQuery == count + symbolsMatched)) { - scoped_ptr<search::TrieIterator>(pIter->GoToEdge(i)).swap(pIter); + pIter.reset(pIter->GoToEdge(i)); bFullEdgeMatched = (count == szEdge); symbolsMatched += count; diff --git a/search/search_query.cpp b/search/search_query.cpp index fddfe33917..c529e06fdc 100644 --- a/search/search_query.cpp +++ b/search/search_query.cpp @@ -336,7 +336,7 @@ namespace shared_ptr<value_type> m_val; public: - IndexedValue(value_type * v) : m_val(v) + explicit IndexedValue(value_type * v) : m_val(v) { for (size_t i = 0; i < m_ind.size(); ++i) m_ind[i] = numeric_limits<size_t>::max(); @@ -403,7 +403,7 @@ namespace // do not insert duplicating results if (indV.end() == find_if(indV.begin(), indV.end(), ProxyFunctor1<impl::PreResult2::StrictEqualF>(p))) - indV.push_back(p); + indV.push_back(T(p)); else delete p; } @@ -1023,13 +1023,7 @@ namespace impl { class DoFindLocality { - class EqualID - { - uint32_t m_id; - public: - EqualID(uint32_t id) : m_id(id) {} - bool operator() (Locality const & l) const { return (l.m_value.m_featureId == m_id); } - }; + Query const & m_query; /// @see Locality::m_index vector<Locality> m_localities[3]; @@ -1092,8 +1086,6 @@ namespace impl int8_t m_lang; int8_t m_arrEn[3]; - Query const & m_query; - void AssignEnglishName(FeatureType const & f, Locality & l) { // search for name in next order: "en", "int_name", "default" @@ -1158,12 +1150,17 @@ namespace impl return false; } - volatile bool & m_isCancelled; + class EqualID + { + uint32_t m_id; + public: + EqualID(uint32_t id) : m_id(id) {} + bool operator() (Locality const & l) const { return (l.m_value.m_featureId == m_id); } + }; public: - DoFindLocality(Query & q, MwmValue * pMwm, int8_t lang, volatile bool & isCancelled) - : m_vector(pMwm->m_cont, pMwm->GetHeader()), m_lang(lang), - m_query(q), m_isCancelled(isCancelled) + DoFindLocality(Query & q, MwmValue * pMwm, int8_t lang) + : m_query(q), m_vector(pMwm->m_cont, pMwm->GetHeader()), m_lang(lang) { m_arrEn[0] = q.GetLanguage(LANG_EN); m_arrEn[1] = q.GetLanguage(LANG_INTERNATIONAL); @@ -1175,7 +1172,7 @@ namespace impl void operator() (Query::TrieValueT const & v) { - if (m_isCancelled) + if (m_query.IsCanceled()) throw Query::CancelException(); // find locality in current results @@ -1300,7 +1297,7 @@ bool Query::SearchLocality(MwmValue * pMwm, impl::Locality & res) { scoped_ptr<TrieIterator> pLangRoot(pTrieRoot->GoToEdge(i)); - impl::DoFindLocality doFind(*this, pMwm, lang, m_cancel); + impl::DoFindLocality doFind(*this, pMwm, lang); GetFeaturesInTrie(params.m_tokens, params.m_prefixTokens, TrieRootPrefix(*pLangRoot, edge), doFind); @@ -1562,7 +1559,7 @@ void Query::SearchAllInViewport(m2::RectD const & viewport, Results & res, unsig InitSearch(string()); - vector<impl::PreResult2*> indV; + vector<shared_ptr<impl::PreResult2> > indV; impl::PreResult2Maker maker(*this); @@ -1596,8 +1593,6 @@ void Query::SearchAllInViewport(m2::RectD const & viewport, Results & res, unsig res.AddResult(MakeResult(*(indV[i]))); } } - - for_each(indV.begin(), indV.end(), DeleteFunctor()); } void Query::SearchAdditional(Results & res) |