diff options
author | Tofu Linden <tofu.linden@lindenlab.com> | 2010-01-27 13:02:19 -0800 |
---|---|---|
committer | Tofu Linden <tofu.linden@lindenlab.com> | 2010-01-27 13:02:19 -0800 |
commit | 2f062b9e5c761bce6d4d29e1a40283e37dfdfd53 (patch) | |
tree | fa946b24cc094e84e2e638db92044155c3b4f4f9 /indra | |
parent | a0bc58aac498dff7f06070bf3be025b5e396f84f (diff) |
CID-105
Checker: INVALIDATE_ITERATOR
Function: LLLocationHistory::addItem(const LLLocationHistoryItem &)
File: /indra/newview/lllocationhistory.cpp
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/lllocationhistory.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/indra/newview/lllocationhistory.cpp b/indra/newview/lllocationhistory.cpp index ae1b8f8540..f494f7d7c1 100644 --- a/indra/newview/lllocationhistory.cpp +++ b/indra/newview/lllocationhistory.cpp @@ -50,18 +50,19 @@ void LLLocationHistory::addItem(const LLLocationHistoryItem& item) { // check if this item doesn't duplicate any existing one location_list_t::iterator item_iter = std::find(mItems.begin(), mItems.end(),item); - if(item_iter != mItems.end()){ + if(item_iter != mItems.end()) // if it already exists, erase the old one + { mItems.erase(item_iter); } mItems.push_back(item); - // If the vector size exceeds the maximum, purge the oldest items. - if ((S32)mItems.size() > max_items) { - for(location_list_t::iterator i = mItems.begin(); i != mItems.end()-max_items; ++i) { - mItems.erase(i); - } + // If the vector size exceeds the maximum, purge the oldest items (at the start of the mItems vector). + if ((S32)mItems.size() > max_items) + { + mItems.erase(mItems.begin(), mItems.end()-max_items); } + llassert(mItems.size() <= max_items); } /* |