aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMarco Poletti <poletti.marco@gmail.com>2017-08-13 10:21:43 +0200
committerMarco Poletti <poletti.marco@gmail.com>2017-08-13 10:21:43 +0200
commitaa951505ace70a07b1591e0cc977185f077cf4ae (patch)
tree8b1f4676513b29967ae31eb3044d225684f35c20 /include
parent6f65f445ad0edb7e5c1749a9249611015e8341db (diff)
downloadgoogle-fruit-aa951505ace70a07b1591e0cc977185f077cf4ae.tar.gz
Only call std::allocator::deallocate() in FixedSizeVector for non-empty vectors. When using a malloc-based std:allocator this was not an issue (since free(0) is a no-op), but it can cause problems with other STL implementations.
Diffstat (limited to 'include')
-rw-r--r--include/fruit/impl/data_structures/fixed_size_vector.defn.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/include/fruit/impl/data_structures/fixed_size_vector.defn.h b/include/fruit/impl/data_structures/fixed_size_vector.defn.h
index 3573181..d5d36f9 100644
--- a/include/fruit/impl/data_structures/fixed_size_vector.defn.h
+++ b/include/fruit/impl/data_structures/fixed_size_vector.defn.h
@@ -42,7 +42,9 @@ inline FixedSizeVector<T, Allocator>::FixedSizeVector(std::size_t capacity, Allo
template <typename T, typename Allocator>
inline FixedSizeVector<T, Allocator>::~FixedSizeVector() {
clear();
- allocator.deallocate(v_begin, capacity);
+ if (capacity != 0) {
+ allocator.deallocate(v_begin, capacity);
+ }
}
template <typename T, typename Allocator>