diff options
author | Paul Gilbert | 2007-09-16 04:03:50 +0000 |
---|---|---|
committer | Paul Gilbert | 2007-09-16 04:03:50 +0000 |
commit | a19f337a0c9e120b0f6101e6df71e2ebfc3a9b9d (patch) | |
tree | 07d54b6eab5996027b38a94b563d0a2503aa4673 | |
parent | bd454d0c796092ce745b1ce32aeb7d022b853216 (diff) | |
download | scummvm-rg350-a19f337a0c9e120b0f6101e6df71e2ebfc3a9b9d.tar.gz scummvm-rg350-a19f337a0c9e120b0f6101e6df71e2ebfc3a9b9d.tar.bz2 scummvm-rg350-a19f337a0c9e120b0f6101e6df71e2ebfc3a9b9d.zip |
Changed ManagedList to make it more thread safe
svn-id: r28914
-rw-r--r-- | engines/lure/res_struct.h | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/engines/lure/res_struct.h b/engines/lure/res_struct.h index f6c1966a93..81ecd87563 100644 --- a/engines/lure/res_struct.h +++ b/engines/lure/res_struct.h @@ -254,23 +254,28 @@ public: } void clear() { - typename Common::List<T>::iterator i; - for (i = Common_List::begin(); i != Common_List::end(); ++i) - delete *i; - Common_List::clear(); + typename Common_List::iterator i = Common_List::begin(); + while (i != Common_List::end()) { + T v = *i; + i = Common_List::erase(i); + delete v; + } } - typename Common::List<T>::iterator erase(typename Common::List<T>::iterator pos) { - delete *pos; - return Common_List::erase(pos); + typename Common_List::iterator erase(typename Common_List::iterator pos) { + T obj = *pos; + typename Common_List::iterator result = Common_List::erase(pos); + delete obj; + return result; } - typename Common::List<T>::iterator erase(typename Common::List<T>::iterator first, - typename Common::List<T>::iterator last) { - typename Common::List<T>::iterator i; - for (i = first; i != last; ++i) - delete *i; - return Common_List::erase(first, last); + typename Common_List::iterator erase(typename Common_List::iterator first, + typename Common_List::iterator last) { + + while (first != last) + erase(first++); + + return last; } }; |