|
From: <sv...@va...> - 2007-03-29 22:32:04
|
Author: njn
Date: 2007-03-29 23:31:57 +0100 (Thu, 29 Mar 2007)
New Revision: 6689
Log:
add a useful test case. Not actually plumbed into the Makefile yet.
Added:
branches/MASSIF2/massif/tests/overloaded-new.cpp
Added: branches/MASSIF2/massif/tests/overloaded-new.cpp
===================================================================
--- branches/MASSIF2/massif/tests/overloaded-new.cpp (rev 0)
+++ branches/MASSIF2/massif/tests/overloaded-new.cpp 2007-03-29 22:31:57 UTC (rev 6689)
@@ -0,0 +1,46 @@
+// operator new(unsigned)
+// operator new[](unsigned)
+// operator new(unsigned, std::nothrow_t const&)
+// operator new[](unsigned, std::nothrow_t const&)
+
+#include <stdlib.h>
+
+#include <new>
+
+using std::nothrow_t;
+
+// A big structure. It's details don't matter.
+struct s {
+ int array[1000];
+};
+
+void* operator new (std::size_t n) throw (std::bad_alloc)
+{
+ return malloc(n);
+}
+
+void* operator new (std::size_t n, std::nothrow_t const &) throw ()
+{
+ return malloc(n);
+}
+
+void* operator new[] (std::size_t n) throw (std::bad_alloc)
+{
+ return malloc(n);
+}
+
+void* operator new[] (std::size_t n, std::nothrow_t const &) throw ()
+{
+ return malloc(n);
+}
+
+int main(void)
+{
+ struct s* p1 = new struct s;
+ struct s* p2 = new (std::nothrow) struct s;
+ char* c1 = new char[2000];
+ char* c2 = new (std::nothrow) char[2000];
+ return 0;
+}
+
+
|