* testsuite/23_containers/vector/zero_sized_allocations.cc:
Define sized deallocation function.
* testsuite/util/testsuite_new_operators.h:
(operator delete(void*, const std::nothrow_t&)): Define nothrow
deallocation function.
From-SVN: r238610
2016-07-21 Jonathan Wakely <jwakely@redhat.com>
+ * testsuite/23_containers/vector/zero_sized_allocations.cc:
+ Define sized deallocation function.
+ * testsuite/util/testsuite_new_operators.h:
+ (operator delete(void*, const std::nothrow_t&)): Define nothrow
+ deallocation function.
+
* testsuite/21_strings/basic_string/modifiers/append/char/1.cc: Fix
reads past the end of strings.
* testsuite/21_strings/basic_string/operations/compare/char/1.cc:
unsigned int zero_sized_news = 0;
-void *operator new(size_t size) throw (std::bad_alloc)
+void *operator new(std::size_t size) throw (std::bad_alloc)
{
/* malloc(0) is unpredictable; avoid it. */
if (size == 0)
std::free(ptr);
}
+#if __cpp_sized_deallocation
+void operator delete(void *ptr, std::size_t) throw()
+{
+ if (ptr != 0)
+ std::free(ptr);
+}
+#endif
+
// http://gcc.gnu.org/ml/libstdc++/2007-09/msg00006.html
void test01()
{
VERIFY( zero_sized_news == 0 );
v->resize(10);
- delete(v);
+ delete v;
VERIFY( zero_sized_news == 0 );
}
std::free(p);
}
+void operator delete(void* p, const std::nothrow_t&) throw()
+{
+ if (p)
+ std::free(p);
+}
+
+
#endif // _GLIBCXX_TESTSUITE_NEW_OPERATORS_H