9661-1.cc: Include <cstdlib>.
[gcc.git] / libstdc++-v3 / testsuite / ext / new_allocator / deallocate_global.cc
index 4a352705c9cdead76e27a423beb2a4d1fad24147..387e715704a9367c593f172c46c0b2a6c3476101 100644 (file)
@@ -1,5 +1,5 @@
 //
-// Copyright (C) 2004 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
 
 #include <string>
 #include <stdexcept>
+#include <cstdlib>
 #include <ext/new_allocator.h>
-#include <testsuite_hooks.h>
 
 static size_t count;
 
 struct count_check
 {
-  count_check() {}
+  count_check() { }
   ~count_check()
   {
     if (count != 0)
-      throw std::runtime_error("count isn't zero");
+      throw std::runtime_error("allocation/deallocation count isn't zero");
   }
 };
  
@@ -40,8 +40,8 @@ static count_check check;
 
 void* operator new(size_t size) throw(std::bad_alloc)
 {
-  printf("operator new is called \n");
-  void* p = malloc(size);
+  std::printf("operator new is called \n");
+  void* p = std::malloc(size);
   if (p == NULL)
     throw std::bad_alloc();
   count++;
@@ -50,15 +50,10 @@ void* operator new(size_t size) throw(std::bad_alloc)
  
 void operator delete(void* p) throw()
 {
-  printf("operator delete is called \n");
+  std::printf("operator delete is called \n");
   if (p == NULL)
     return;
   count--;
-  if (count == 0)
-    printf("All memory released \n");
-  else
-    printf("%u allocations to be released \n", count);
-  free(p);
 }
 
 typedef char char_t;