OSDN Git Service

2009-05-28 Benjamin Kosnik <bkoz@redhat.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / testsuite / ext / mt_allocator / deallocate_global_thread-1.cc
index 6881c9f..f61cd38 100644 (file)
 #include <stdexcept>
 #include <cstdio>
 #include <ext/mt_allocator.h>
-
-static size_t count;
-
-struct count_check
-{
-  count_check() { }
-  ~count_check()
-  {
-    // NB: __mt_allocator doesn't clean itself up. Thus, this will not
-    // be zero.
-    if (count != 0)
-      {
-       //throw std::runtime_error("allocation/deallocation count isn't zero");
-       printf("allocation/deallocation count is %zu \n", count);
-      }
-  }
-};
-static count_check check;
-
-void* operator new(size_t size) throw(std::bad_alloc)
-{
-  printf("operator new is called \n");
-  void* p = malloc(size);
-  if (p == NULL)
-    throw std::bad_alloc();
-  count++;
-  return p;
-}
-void operator delete(void* p) throw()
-{
-  printf("operator delete is called \n");
-  if (p == NULL)
-    return;
-  count--;
-}
+#include <replacement_memory_operators.h>
 
 typedef std::string value_type;
 using __gnu_cxx::__pool;
@@ -74,6 +38,9 @@ list_type l;
 
 int main()
 {
+  // NB: __mt_allocator doesn't clean itself up. Thus, the count will
+  // not be zero.
+  __gnu_test::counter::exceptions(false);
   l.push_back("bayou bend");
   return 0;
 }