Add STLDeleteValues, and use it.
This is the version from Chromium.
Change-Id: I5b7c6a544d5d5db8244869c58461cad16e7b4b86
diff --git a/src/stl_util.h b/src/stl_util.h
index 024f162..5fcf089 100644
--- a/src/stl_util.h
+++ b/src/stl_util.h
@@ -42,6 +42,18 @@
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_