forked from mirror/OpenTTD
Remove: AutoFreeSmallVector.
The last use was for storing a list of memory blocks. As the way these lists are accessed is very specific, it is easier to just write an explicit destructor instead of trying to exactly match the behaviour.
This commit is contained in:
@@ -69,34 +69,4 @@ T* grow(std::vector<T>& vec, std::size_t num)
|
||||
return vec.data() + pos;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
template <typename T>
|
||||
class AutoFreeSmallVector : public std::vector<T> {
|
||||
public:
|
||||
~AutoFreeSmallVector()
|
||||
{
|
||||
this->Clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all items from the list.
|
||||
*/
|
||||
inline void Clear()
|
||||
{
|
||||
for (T p : *this) {
|
||||
free(p);
|
||||
}
|
||||
|
||||
std::vector<T>::clear();
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* SMALLVEC_TYPE_HPP */
|
||||
|
Reference in New Issue
Block a user