summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2008-07-22 14:17:29 +0000
committerpeter1138 <peter1138@openttd.org>2008-07-22 14:17:29 +0000
commit2466b7f01e91894f77b678c67a08b33cd3786a40 (patch)
treeb2e961145afab9789e1c16e73b55d3e400578b1c /src/core
parentb81e31bdb1728173e62f0b48d872e9b8a9f4e788 (diff)
downloadopenttd-2466b7f01e91894f77b678c67a08b33cd3786a40.tar.xz
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/smallvec_type.hpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/core/smallvec_type.hpp b/src/core/smallvec_type.hpp
index 4da1a66a8..709ff70f0 100644
--- a/src/core/smallvec_type.hpp
+++ b/src/core/smallvec_type.hpp
@@ -162,4 +162,36 @@ public:
}
};
+
+/**
+ * Simple vector template class, with automatic free.
+ *
+ * @note There are no asserts in the class so you have
+ * to care about that you grab an item which is
+ * inside the list.
+ *
+ * @param T The type of the items stored, must be a pointer
+ * @param S The steps of allocation
+ */
+template <typename T, uint S>
+class AutoFreeSmallVector : public SmallVector<T, S> {
+public:
+ ~AutoFreeSmallVector()
+ {
+ this->Clear();
+ }
+
+ /**
+ * Remove all items from the list.
+ */
+ FORCEINLINE void Clear()
+ {
+ for (uint i = 0; i < this->items; i++) {
+ free(this->data[i]);
+ }
+
+ this->items = 0;
+ }
+};
+
#endif /* SMALLVEC_TYPE_HPP */