This is the version from Chromium.
Change-Id: I5b7c6a544d5d5db8244869c58461cad16e7b4b86
#include "object.h"
#include "runtime.h"
#include "scoped_jni_thread_state.h"
+#include "stl_util.h"
#include "stringpiece.h"
#include "thread.h"
}
~Libraries() {
- // Delete our map values. (The keys will be cleaned up by the map itself.)
- for (It it = libraries_.begin(); it != libraries_.end(); ++it) {
- delete it->second;
- }
+ STLDeleteValues(&libraries_);
}
SharedLibrary* Get(const std::string& path) {
container->clear();
}
+// Given an STL container consisting of (key, value) pairs, STLDeleteValues
+// deletes all the "value" components and clears the container. Does nothing
+// in the case it's given a NULL pointer.
+template <class T>
+void STLDeleteValues(T *v) {
+ if (!v) return;
+ for (typename T::iterator i = v->begin(); i != v->end(); ++i) {
+ delete i->second;
+ }
+ v->clear();
+}
+
} // namespace art
#endif // ART_SRC_STL_UTIL_H_