//
-// 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");
}
};
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++;
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;