testsuite_allocator.h (check_new, [...]): Move to ...
2009-05-28 Benjamin Kosnik <bkoz@redhat.com> * testsuite/util/testsuite_allocator.h (check_new, check_delete): Move to ... * testsuite/util/replacement_memory_operators.h: ...here. New. * testsuite/util/testsuite_hooks.h (counter): To object_counter. * testsuite/util/testsuite_hooks.cc: Same. * testsuite/ext/mt_allocator/deallocate_local_thread-1.cc: Use replacement_memory_operators.h. * testsuite/ext/mt_allocator/deallocate_local_thread-3.cc: Same. * testsuite/ext/mt_allocator/check_delete.cc: Same. * testsuite/ext/mt_allocator/deallocate_local_thread-5.cc: Same. * testsuite/ext/mt_allocator/deallocate_local_thread-7.cc: Same. * testsuite/ext/mt_allocator/deallocate_global_thread-1.cc: Same. * testsuite/ext/mt_allocator/deallocate_global_thread-3.cc: Same. * testsuite/ext/mt_allocator/deallocate_local-2.cc: Same. * testsuite/ext/mt_allocator/deallocate_local-4.cc: Same. * testsuite/ext/mt_allocator/deallocate_local-6.cc: Same. * testsuite/ext/mt_allocator/deallocate_local-8.cc: Same. * testsuite/ext/mt_allocator/deallocate_global-2.cc: Same. * testsuite/ext/mt_allocator/deallocate_global-4.cc: Same. * testsuite/ext/mt_allocator/check_new.cc: Same. * testsuite/ext/debug_allocator/check_delete.cc: Same. * testsuite/ext/debug_allocator/check_new.cc: Same. * testsuite/ext/new_allocator/deallocate_global.cc: Same. * testsuite/ext/new_allocator/check_delete.cc: Same. * testsuite/ext/new_allocator/check_new.cc: Same. * testsuite/ext/new_allocator/deallocate_local.cc: Same. * testsuite/ext/throw_allocator/deallocate_global.cc: Same. * testsuite/ext/throw_allocator/check_delete.cc: Same. * testsuite/ext/throw_allocator/check_new.cc: Same. * testsuite/ext/throw_allocator/deallocate_local.cc: Same. * testsuite/ext/malloc_allocator/deallocate_global.cc: Same. * testsuite/ext/malloc_allocator/check_delete.cc: Same. * testsuite/ext/malloc_allocator/check_new.cc: Same. * testsuite/ext/malloc_allocator/deallocate_local.cc: Same. * testsuite/ext/pool_allocator/check_delete.cc: Same. * testsuite/ext/pool_allocator/check_new.cc: Same. * testsuite/ext/bitmap_allocator/check_delete.cc: Same. * testsuite/ext/bitmap_allocator/check_new.cc: Same. * testsuite/ext/array_allocator/check_delete.cc: Same. * testsuite/ext/array_allocator/check_new.cc: Same. * testsuite/23_containers/deque/cons/1.cc: Same. * testsuite/23_containers/deque/cons/2.cc: Same. From-SVN: r147937
This commit is contained in:
parent
e455776af0
commit
daa159291b
@ -1,3 +1,49 @@
|
||||
2009-05-28 Benjamin Kosnik <bkoz@redhat.com>
|
||||
|
||||
* testsuite/util/testsuite_allocator.h (check_new, check_delete): Move
|
||||
to ...
|
||||
* testsuite/util/replacement_memory_operators.h: ...here. New.
|
||||
* testsuite/util/testsuite_hooks.h (counter): To object_counter.
|
||||
* testsuite/util/testsuite_hooks.cc: Same.
|
||||
|
||||
* testsuite/ext/mt_allocator/deallocate_local_thread-1.cc: Use
|
||||
replacement_memory_operators.h.
|
||||
* testsuite/ext/mt_allocator/deallocate_local_thread-3.cc: Same.
|
||||
* testsuite/ext/mt_allocator/check_delete.cc: Same.
|
||||
* testsuite/ext/mt_allocator/deallocate_local_thread-5.cc: Same.
|
||||
* testsuite/ext/mt_allocator/deallocate_local_thread-7.cc: Same.
|
||||
* testsuite/ext/mt_allocator/deallocate_global_thread-1.cc: Same.
|
||||
* testsuite/ext/mt_allocator/deallocate_global_thread-3.cc: Same.
|
||||
* testsuite/ext/mt_allocator/deallocate_local-2.cc: Same.
|
||||
* testsuite/ext/mt_allocator/deallocate_local-4.cc: Same.
|
||||
* testsuite/ext/mt_allocator/deallocate_local-6.cc: Same.
|
||||
* testsuite/ext/mt_allocator/deallocate_local-8.cc: Same.
|
||||
* testsuite/ext/mt_allocator/deallocate_global-2.cc: Same.
|
||||
* testsuite/ext/mt_allocator/deallocate_global-4.cc: Same.
|
||||
* testsuite/ext/mt_allocator/check_new.cc: Same.
|
||||
* testsuite/ext/debug_allocator/check_delete.cc: Same.
|
||||
* testsuite/ext/debug_allocator/check_new.cc: Same.
|
||||
* testsuite/ext/new_allocator/deallocate_global.cc: Same.
|
||||
* testsuite/ext/new_allocator/check_delete.cc: Same.
|
||||
* testsuite/ext/new_allocator/check_new.cc: Same.
|
||||
* testsuite/ext/new_allocator/deallocate_local.cc: Same.
|
||||
* testsuite/ext/throw_allocator/deallocate_global.cc: Same.
|
||||
* testsuite/ext/throw_allocator/check_delete.cc: Same.
|
||||
* testsuite/ext/throw_allocator/check_new.cc: Same.
|
||||
* testsuite/ext/throw_allocator/deallocate_local.cc: Same.
|
||||
* testsuite/ext/malloc_allocator/deallocate_global.cc: Same.
|
||||
* testsuite/ext/malloc_allocator/check_delete.cc: Same.
|
||||
* testsuite/ext/malloc_allocator/check_new.cc: Same.
|
||||
* testsuite/ext/malloc_allocator/deallocate_local.cc: Same.
|
||||
* testsuite/ext/pool_allocator/check_delete.cc: Same.
|
||||
* testsuite/ext/pool_allocator/check_new.cc: Same.
|
||||
* testsuite/ext/bitmap_allocator/check_delete.cc: Same.
|
||||
* testsuite/ext/bitmap_allocator/check_new.cc: Same.
|
||||
* testsuite/ext/array_allocator/check_delete.cc: Same.
|
||||
* testsuite/ext/array_allocator/check_new.cc: Same.
|
||||
* testsuite/23_containers/deque/cons/1.cc: Same.
|
||||
* testsuite/23_containers/deque/cons/2.cc: Same.
|
||||
|
||||
2009-05-27 Benjamin Kosnik <bkoz@redhat.com>
|
||||
|
||||
* libsupc++/initializer_list: Format.
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <testsuite_allocator.h>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
typedef std::deque<__gnu_test::counter> gdeque;
|
||||
typedef std::deque<__gnu_test::object_counter> gdeque;
|
||||
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
|
@ -31,10 +31,10 @@ using __gnu_test::tracker_allocator_counter;
|
||||
using __gnu_test::tracker_allocator;
|
||||
using __gnu_test::copy_constructor;
|
||||
using __gnu_test::assignment_operator;
|
||||
using __gnu_test::counter;
|
||||
using __gnu_test::object_counter;
|
||||
using __gnu_test::destructor;
|
||||
|
||||
typedef std::deque<counter> gdeque;
|
||||
typedef std::deque<object_counter> gdeque;
|
||||
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
|
@ -21,40 +21,15 @@
|
||||
|
||||
#include <cstdlib>
|
||||
#include <ext/array_allocator.h>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_allocator.h>
|
||||
|
||||
using __gnu_cxx::array_allocator;
|
||||
|
||||
void*
|
||||
operator new(std::size_t n) throw(std::bad_alloc)
|
||||
{
|
||||
new_called = true;
|
||||
return std::malloc(n);
|
||||
}
|
||||
|
||||
void
|
||||
operator delete(void *v) throw()
|
||||
{
|
||||
delete_called = true;
|
||||
return std::free(v);
|
||||
}
|
||||
|
||||
// These just help tracking down error messages.
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
typedef unsigned int value_type;
|
||||
typedef std::tr1::array<value_type, 15> array_type;
|
||||
typedef array_allocator<value_type, array_type> allocator_type;
|
||||
array_type store;
|
||||
allocator_type a(&store);
|
||||
VERIFY( bool(__gnu_test::check_delete<allocator_type, false>(a)) );
|
||||
}
|
||||
#include <replacement_memory_operators.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
{
|
||||
typedef unsigned int value_type;
|
||||
typedef std::tr1::array<value_type, 15> array_type;
|
||||
typedef __gnu_cxx::array_allocator<value_type, array_type> allocator_type;
|
||||
array_type store;
|
||||
allocator_type a(&store);
|
||||
__gnu_test::check_delete<allocator_type, false>(a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -21,40 +21,15 @@
|
||||
|
||||
#include <cstdlib>
|
||||
#include <ext/array_allocator.h>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_allocator.h>
|
||||
|
||||
using __gnu_cxx::array_allocator;
|
||||
|
||||
void*
|
||||
operator new(std::size_t n) throw(std::bad_alloc)
|
||||
{
|
||||
new_called = true;
|
||||
return std::malloc(n);
|
||||
}
|
||||
|
||||
void
|
||||
operator delete(void *v) throw()
|
||||
{
|
||||
delete_called = true;
|
||||
return std::free(v);
|
||||
}
|
||||
|
||||
// These just help tracking down error messages.
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
typedef unsigned int value_type;
|
||||
typedef std::tr1::array<value_type, 15> array_type;
|
||||
typedef array_allocator<value_type, array_type> allocator_type;
|
||||
array_type store;
|
||||
allocator_type a(&store);
|
||||
VERIFY( bool(__gnu_test::check_new<allocator_type, false>(a)) );
|
||||
}
|
||||
#include <replacement_memory_operators.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
{
|
||||
typedef unsigned int value_type;
|
||||
typedef std::tr1::array<value_type, 15> array_type;
|
||||
typedef __gnu_cxx::array_allocator<value_type, array_type> allocator_type;
|
||||
array_type store;
|
||||
allocator_type a(&store);
|
||||
__gnu_test::check_new<allocator_type, false>(a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -19,35 +19,11 @@
|
||||
|
||||
#include <cstdlib>
|
||||
#include <ext/bitmap_allocator.h>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_allocator.h>
|
||||
|
||||
using __gnu_cxx::bitmap_allocator;
|
||||
|
||||
void*
|
||||
operator new(std::size_t n) throw(std::bad_alloc)
|
||||
{
|
||||
new_called = true;
|
||||
return std::malloc(n);
|
||||
}
|
||||
|
||||
void
|
||||
operator delete(void *v) throw()
|
||||
{
|
||||
delete_called = true;
|
||||
return std::free(v);
|
||||
}
|
||||
|
||||
// These just help tracking down error messages.
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
typedef bitmap_allocator<unsigned int> allocator_type;
|
||||
VERIFY( bool(__gnu_test::check_delete<allocator_type, true>()) );
|
||||
}
|
||||
#include <replacement_memory_operators.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
{
|
||||
typedef __gnu_cxx::bitmap_allocator<unsigned int> allocator_type;
|
||||
__gnu_test::check_delete<allocator_type, true>();
|
||||
return 0;
|
||||
}
|
||||
|
@ -19,35 +19,11 @@
|
||||
|
||||
#include <cstdlib>
|
||||
#include <ext/bitmap_allocator.h>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_allocator.h>
|
||||
|
||||
using __gnu_cxx::bitmap_allocator;
|
||||
|
||||
void*
|
||||
operator new(std::size_t n) throw(std::bad_alloc)
|
||||
{
|
||||
new_called = true;
|
||||
return std::malloc(n);
|
||||
}
|
||||
|
||||
void
|
||||
operator delete(void *v) throw()
|
||||
{
|
||||
delete_called = true;
|
||||
return std::free(v);
|
||||
}
|
||||
|
||||
// These just help tracking down error messages.
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
typedef bitmap_allocator<unsigned int> allocator_type;
|
||||
VERIFY( bool(__gnu_test::check_new<allocator_type, true>()) );
|
||||
}
|
||||
#include <replacement_memory_operators.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
{
|
||||
typedef __gnu_cxx::bitmap_allocator<unsigned int> allocator_type;
|
||||
__gnu_test::check_new<allocator_type, true>();
|
||||
return 0;
|
||||
}
|
||||
|
@ -22,37 +22,12 @@
|
||||
#include <cstdlib>
|
||||
#include <ext/debug_allocator.h>
|
||||
#include <ext/malloc_allocator.h>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_allocator.h>
|
||||
|
||||
using __gnu_cxx::malloc_allocator;
|
||||
using __gnu_cxx::debug_allocator;
|
||||
|
||||
void*
|
||||
operator new(std::size_t n) throw(std::bad_alloc)
|
||||
{
|
||||
new_called = true;
|
||||
return std::malloc(n);
|
||||
}
|
||||
|
||||
void
|
||||
operator delete(void *v) throw()
|
||||
{
|
||||
delete_called = true;
|
||||
return std::free(v);
|
||||
}
|
||||
|
||||
// These just help tracking down error messages.
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
typedef debug_allocator<malloc_allocator<unsigned int> > allocator_type;
|
||||
VERIFY( bool(__gnu_test::check_delete<allocator_type, false>()) );
|
||||
}
|
||||
#include <replacement_memory_operators.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
{
|
||||
using namespace __gnu_cxx;
|
||||
typedef debug_allocator<malloc_allocator<unsigned int> > allocator_type;
|
||||
__gnu_test::check_delete<allocator_type, false>();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -22,37 +22,12 @@
|
||||
#include <cstdlib>
|
||||
#include <ext/debug_allocator.h>
|
||||
#include <ext/malloc_allocator.h>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_allocator.h>
|
||||
|
||||
using __gnu_cxx::malloc_allocator;
|
||||
using __gnu_cxx::debug_allocator;
|
||||
|
||||
void*
|
||||
operator new(std::size_t n) throw(std::bad_alloc)
|
||||
{
|
||||
new_called = true;
|
||||
return std::malloc(n);
|
||||
}
|
||||
|
||||
void
|
||||
operator delete(void *v) throw()
|
||||
{
|
||||
delete_called = true;
|
||||
return std::free(v);
|
||||
}
|
||||
|
||||
// These just help tracking down error messages.
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
typedef debug_allocator<malloc_allocator<unsigned int> > allocator_type;
|
||||
VERIFY( bool(__gnu_test::check_new<allocator_type, false>()) );
|
||||
}
|
||||
#include <replacement_memory_operators.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
{
|
||||
using namespace __gnu_cxx;
|
||||
typedef debug_allocator<malloc_allocator<unsigned int> > allocator_type;
|
||||
__gnu_test::check_new<allocator_type, false>();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -21,36 +21,11 @@
|
||||
|
||||
#include <cstdlib>
|
||||
#include <ext/malloc_allocator.h>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_allocator.h>
|
||||
|
||||
using __gnu_cxx::malloc_allocator;
|
||||
|
||||
void*
|
||||
operator new(std::size_t n) throw(std::bad_alloc)
|
||||
{
|
||||
new_called = true;
|
||||
return std::malloc(n);
|
||||
}
|
||||
|
||||
void
|
||||
operator delete(void *v) throw()
|
||||
{
|
||||
delete_called = true;
|
||||
return std::free(v);
|
||||
}
|
||||
|
||||
// These just help tracking down error messages.
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
typedef malloc_allocator<unsigned int> allocator_type;
|
||||
VERIFY( bool(__gnu_test::check_delete<allocator_type, false>()) );
|
||||
}
|
||||
#include <replacement_memory_operators.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
{
|
||||
typedef __gnu_cxx::malloc_allocator<unsigned int> allocator_type;
|
||||
__gnu_test::check_delete<allocator_type, false>();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -21,36 +21,11 @@
|
||||
|
||||
#include <cstdlib>
|
||||
#include <ext/malloc_allocator.h>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_allocator.h>
|
||||
|
||||
using __gnu_cxx::malloc_allocator;
|
||||
|
||||
void*
|
||||
operator new(std::size_t n) throw(std::bad_alloc)
|
||||
{
|
||||
new_called = true;
|
||||
return std::malloc(n);
|
||||
}
|
||||
|
||||
void
|
||||
operator delete(void *v) throw()
|
||||
{
|
||||
delete_called = true;
|
||||
return std::free(v);
|
||||
}
|
||||
|
||||
// These just help tracking down error messages.
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
typedef malloc_allocator<unsigned int> allocator_type;
|
||||
VERIFY( bool(__gnu_test::check_new<allocator_type, false>()) );
|
||||
}
|
||||
#include <replacement_memory_operators.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
{
|
||||
typedef __gnu_cxx::malloc_allocator<unsigned int> allocator_type;
|
||||
__gnu_test::check_new<allocator_type, false>();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -17,56 +17,15 @@
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// 20.4.1.1 allocator members
|
||||
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <cstdio>
|
||||
#include <ext/malloc_allocator.h>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
static size_t count;
|
||||
|
||||
struct count_check
|
||||
{
|
||||
count_check() {}
|
||||
~count_check()
|
||||
{
|
||||
if (count != 0)
|
||||
throw std::runtime_error("count isn't zero");
|
||||
}
|
||||
};
|
||||
|
||||
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--;
|
||||
if (count == 0)
|
||||
printf("All memory released \n");
|
||||
else
|
||||
printf("%lu allocations to be released \n",
|
||||
static_cast<unsigned long>(count));
|
||||
free(p);
|
||||
}
|
||||
#include <replacement_memory_operators.h>
|
||||
|
||||
typedef char char_t;
|
||||
typedef std::char_traits<char_t> traits_t;
|
||||
typedef __gnu_cxx::malloc_allocator<char_t> allocator_t;
|
||||
typedef std::basic_string<char_t, traits_t, allocator_t> string_t;
|
||||
typedef std::basic_string<char_t, traits_t, allocator_t> string_t;
|
||||
|
||||
string_t s("bayou bend");
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
|
||||
// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
|
||||
// Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
@ -17,51 +17,23 @@
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// 20.4.1.1 allocator members
|
||||
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include <ext/malloc_allocator.h>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
static size_t alloc_cnt;
|
||||
|
||||
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();
|
||||
alloc_cnt++;
|
||||
return p;
|
||||
}
|
||||
|
||||
void operator delete(void* p) throw()
|
||||
{
|
||||
printf("operator delete is called \n");
|
||||
if (p == NULL)
|
||||
return;
|
||||
alloc_cnt--;
|
||||
if (alloc_cnt == 0)
|
||||
printf("All memory released \n");
|
||||
else
|
||||
printf("%lu allocations to be released \n",
|
||||
static_cast<unsigned long>(alloc_cnt));
|
||||
free(p);
|
||||
}
|
||||
#include <replacement_memory_operators.h>
|
||||
|
||||
typedef char char_t;
|
||||
typedef std::char_traits<char_t> traits_t;
|
||||
typedef __gnu_cxx::malloc_allocator<char_t> allocator_t;
|
||||
typedef std::basic_string<char_t, traits_t, allocator_t> string_t;
|
||||
typedef std::basic_string<char_t, traits_t, allocator_t> string_t;
|
||||
|
||||
int main()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
{
|
||||
string_t s;
|
||||
s += "bayou bend";
|
||||
}
|
||||
VERIFY( alloc_cnt == 0 );
|
||||
|
||||
if (__gnu_test::counter::count() != 0)
|
||||
throw std::runtime_error("count not zero");
|
||||
return 0;
|
||||
}
|
||||
|
@ -21,34 +21,11 @@
|
||||
|
||||
#include <cstdlib>
|
||||
#include <ext/mt_allocator.h>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_allocator.h>
|
||||
|
||||
using __gnu_cxx::__mt_alloc;
|
||||
|
||||
void*
|
||||
operator new(std::size_t n) throw(std::bad_alloc)
|
||||
{
|
||||
new_called = true;
|
||||
return std::malloc(n);
|
||||
}
|
||||
|
||||
void
|
||||
operator delete(void* v) throw()
|
||||
{
|
||||
delete_called = true;
|
||||
return std::free(v);
|
||||
}
|
||||
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
typedef __mt_alloc<unsigned int> allocator_type;
|
||||
VERIFY( bool(__gnu_test::check_delete<allocator_type, false>()) );
|
||||
}
|
||||
#include <replacement_memory_operators.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
{
|
||||
typedef __gnu_cxx::__mt_alloc<unsigned int> allocator_type;
|
||||
__gnu_test::check_delete<allocator_type, false>();
|
||||
return 0;
|
||||
}
|
||||
|
@ -21,35 +21,12 @@
|
||||
|
||||
#include <cstdlib>
|
||||
#include <ext/mt_allocator.h>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_allocator.h>
|
||||
|
||||
using __gnu_cxx::__mt_alloc;
|
||||
|
||||
void*
|
||||
operator new(std::size_t n) throw(std::bad_alloc)
|
||||
{
|
||||
new_called = true;
|
||||
return std::malloc(n);
|
||||
}
|
||||
|
||||
void
|
||||
operator delete(void* v) throw()
|
||||
{
|
||||
delete_called = true;
|
||||
return std::free(v);
|
||||
}
|
||||
|
||||
void test01()
|
||||
{
|
||||
// Uses new but delete only optionally.
|
||||
bool test __attribute__((unused)) = true;
|
||||
typedef __mt_alloc<unsigned int> allocator_type;
|
||||
VERIFY( bool(__gnu_test::check_new<allocator_type, true>()) );
|
||||
}
|
||||
#include <replacement_memory_operators.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
{
|
||||
// Uses new but delete only optionally.
|
||||
typedef __gnu_cxx::__mt_alloc<unsigned int> allocator_type;
|
||||
__gnu_test::check_new<allocator_type, true>();
|
||||
return 0;
|
||||
}
|
||||
|
@ -24,43 +24,7 @@
|
||||
#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;
|
||||
}
|
||||
|
@ -24,43 +24,7 @@
|
||||
#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_t;
|
||||
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;
|
||||
}
|
||||
|
@ -24,43 +24,7 @@
|
||||
#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;
|
||||
}
|
||||
|
@ -24,43 +24,7 @@
|
||||
#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;
|
||||
}
|
||||
|
@ -23,43 +23,7 @@
|
||||
#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 char value_type;
|
||||
typedef std::char_traits<value_type> traits_type;
|
||||
@ -70,6 +34,9 @@ typedef std::basic_string<value_type, traits_type, allocator_type> string_type;
|
||||
|
||||
int main()
|
||||
{
|
||||
// NB: __mt_allocator doesn't clean itself up. Thus, the count will
|
||||
// not be zero.
|
||||
__gnu_test::counter::exceptions(false);
|
||||
string_type s;
|
||||
s += "bayou bend";
|
||||
return 0;
|
||||
|
@ -23,43 +23,7 @@
|
||||
#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)
|
||||
{
|
||||
printf("allocation/deallocation count is %zu \n", count);
|
||||
//throw std::runtime_error("allocation/deallocation count isn't zero");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
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 char value_type;
|
||||
typedef std::char_traits<value_type> traits_type;
|
||||
@ -71,6 +35,9 @@ typedef std::basic_string<value_type, traits_type, allocator_type> string_type;
|
||||
|
||||
int main()
|
||||
{
|
||||
// NB: __mt_allocator doesn't clean itself up. Thus, the count will
|
||||
// not be zero.
|
||||
__gnu_test::counter::exceptions(false);
|
||||
string_type s;
|
||||
s += "bayou bend";
|
||||
return 0;
|
||||
|
@ -24,42 +24,7 @@
|
||||
#include <stdexcept>
|
||||
#include <cstdio>
|
||||
#include <ext/mt_allocator.h>
|
||||
|
||||
static size_t count;
|
||||
|
||||
struct count_check
|
||||
{
|
||||
count_check() { }
|
||||
~count_check()
|
||||
{
|
||||
// NB: Using a pool that attempts to clean up resource use.
|
||||
if (count != 0)
|
||||
{
|
||||
printf("allocation/deallocation count is %zu \n", count);
|
||||
throw std::runtime_error("allocation/deallocation count isn't zero");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
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>
|
||||
|
||||
template<bool _Thread>
|
||||
struct cleanup_pool : public __gnu_cxx::__pool<false>
|
||||
@ -81,6 +46,9 @@ typedef std::basic_string<value_type, traits_type, allocator_type> string_type;
|
||||
|
||||
int main()
|
||||
{
|
||||
// NB: __mt_allocator doesn't clean itself up. Thus, the count will
|
||||
// not be zero.
|
||||
__gnu_test::counter::exceptions(false);
|
||||
string_type s;
|
||||
s += "bayou bend";
|
||||
return 0;
|
||||
|
@ -24,42 +24,7 @@
|
||||
#include <stdexcept>
|
||||
#include <cstdio>
|
||||
#include <ext/mt_allocator.h>
|
||||
|
||||
static size_t count;
|
||||
|
||||
struct count_check
|
||||
{
|
||||
count_check() { }
|
||||
~count_check()
|
||||
{
|
||||
// NB: Using a pool that attempts to clean up resource use.
|
||||
if (count != 0)
|
||||
{
|
||||
printf("allocation/deallocation count is %zu \n", count);
|
||||
throw std::runtime_error("allocation/deallocation count isn't zero");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
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>
|
||||
|
||||
template<bool _Thread>
|
||||
struct cleanup_pool : public __gnu_cxx::__pool<false>
|
||||
@ -82,6 +47,9 @@ typedef std::basic_string<value_type, traits_type, allocator_type> string_type;
|
||||
|
||||
int main()
|
||||
{
|
||||
// NB: __mt_allocator doesn't clean itself up. Thus, the count will
|
||||
// not be zero.
|
||||
__gnu_test::counter::exceptions(false);
|
||||
string_type s;
|
||||
s += "bayou bend";
|
||||
return 0;
|
||||
|
@ -23,43 +23,7 @@
|
||||
#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 char value_type;
|
||||
typedef std::char_traits<value_type> traits_type;
|
||||
@ -70,6 +34,9 @@ typedef std::basic_string<value_type, traits_type, allocator_type> string_type;
|
||||
|
||||
int main()
|
||||
{
|
||||
// NB: __mt_allocator doesn't clean itself up. Thus, the count will
|
||||
// not be zero.
|
||||
__gnu_test::counter::exceptions(false);
|
||||
string_type s;
|
||||
s += "bayou bend";
|
||||
return 0;
|
||||
|
@ -23,43 +23,7 @@
|
||||
#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 char value_type;
|
||||
typedef std::char_traits<value_type> traits_type;
|
||||
@ -71,6 +35,9 @@ typedef std::basic_string<value_type, traits_type, allocator_type> string_type;
|
||||
|
||||
int main()
|
||||
{
|
||||
// NB: __mt_allocator doesn't clean itself up. Thus, the count will
|
||||
// not be zero.
|
||||
__gnu_test::counter::exceptions(false);
|
||||
string_type s;
|
||||
s += "bayou bend";
|
||||
return 0;
|
||||
|
@ -24,42 +24,7 @@
|
||||
#include <stdexcept>
|
||||
#include <cstdio>
|
||||
#include <ext/mt_allocator.h>
|
||||
|
||||
static size_t count;
|
||||
|
||||
struct count_check
|
||||
{
|
||||
count_check() { }
|
||||
~count_check()
|
||||
{
|
||||
// NB: Using a pool that attempts to clean up resource use.
|
||||
if (count != 0)
|
||||
{
|
||||
printf("allocation/deallocation count is %zu \n", count);
|
||||
throw std::runtime_error("allocation/deallocation count isn't zero");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
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>
|
||||
|
||||
template<bool _Thread>
|
||||
struct cleanup_pool : public __gnu_cxx::__pool<true>
|
||||
@ -72,7 +37,6 @@ template<bool _Thread>
|
||||
~cleanup_pool() throw() { this->_M_destroy(); }
|
||||
};
|
||||
|
||||
|
||||
typedef char value_type;
|
||||
typedef std::char_traits<value_type> traits_type;
|
||||
typedef __gnu_cxx::__common_pool_policy<cleanup_pool, true> policy_type;
|
||||
@ -81,6 +45,9 @@ typedef std::basic_string<value_type, traits_type, allocator_type> string_type;
|
||||
|
||||
int main()
|
||||
{
|
||||
// NB: __mt_allocator doesn't clean itself up. Thus, the count will
|
||||
// not be zero.
|
||||
__gnu_test::counter::exceptions(false);
|
||||
string_type s;
|
||||
s += "bayou bend";
|
||||
return 0;
|
||||
|
@ -24,42 +24,7 @@
|
||||
#include <stdexcept>
|
||||
#include <cstdio>
|
||||
#include <ext/mt_allocator.h>
|
||||
|
||||
static size_t count;
|
||||
|
||||
struct count_check
|
||||
{
|
||||
count_check() { }
|
||||
~count_check()
|
||||
{
|
||||
// NB: Using a pool that attempts to clean up resource use.
|
||||
if (count != 0)
|
||||
{
|
||||
printf("allocation/deallocation count is %zu \n", count);
|
||||
throw std::runtime_error("allocation/deallocation count isn't zero");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
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>
|
||||
|
||||
template<bool _Thread>
|
||||
struct cleanup_pool : public __gnu_cxx::__pool<true>
|
||||
@ -82,6 +47,9 @@ typedef std::basic_string<value_type, traits_type, allocator_type> string_type;
|
||||
|
||||
int main()
|
||||
{
|
||||
// NB: __mt_allocator doesn't clean itself up. Thus, the count will
|
||||
// not be zero.
|
||||
__gnu_test::counter::exceptions(false);
|
||||
string_type s;
|
||||
s += "bayou bend";
|
||||
return 0;
|
||||
|
@ -21,36 +21,11 @@
|
||||
|
||||
#include <cstdlib>
|
||||
#include <ext/new_allocator.h>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_allocator.h>
|
||||
|
||||
using __gnu_cxx::new_allocator;
|
||||
|
||||
void*
|
||||
operator new(std::size_t n) throw(std::bad_alloc)
|
||||
{
|
||||
new_called = true;
|
||||
return std::malloc(n);
|
||||
}
|
||||
|
||||
void
|
||||
operator delete(void *v) throw()
|
||||
{
|
||||
delete_called = true;
|
||||
return std::free(v);
|
||||
}
|
||||
|
||||
// These just help tracking down error messages.
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
typedef new_allocator<unsigned int> allocator_type;
|
||||
VERIFY( bool(__gnu_test::check_delete<allocator_type, true>()) );
|
||||
}
|
||||
#include <replacement_memory_operators.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
{
|
||||
typedef __gnu_cxx::new_allocator<unsigned int> allocator_type;
|
||||
__gnu_test::check_delete<allocator_type, true>();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -21,36 +21,11 @@
|
||||
|
||||
#include <cstdlib>
|
||||
#include <ext/new_allocator.h>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_allocator.h>
|
||||
|
||||
using __gnu_cxx::new_allocator;
|
||||
|
||||
void*
|
||||
operator new(std::size_t n) throw(std::bad_alloc)
|
||||
{
|
||||
new_called = true;
|
||||
return std::malloc(n);
|
||||
}
|
||||
|
||||
void
|
||||
operator delete(void *v) throw()
|
||||
{
|
||||
delete_called = true;
|
||||
return std::free(v);
|
||||
}
|
||||
|
||||
// These just help tracking down error messages.
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
typedef new_allocator<unsigned int> allocator_type;
|
||||
VERIFY( bool(__gnu_test::check_new<allocator_type, true>()) );
|
||||
}
|
||||
#include <replacement_memory_operators.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
{
|
||||
typedef __gnu_cxx::new_allocator<unsigned int> allocator_type;
|
||||
__gnu_test::check_new<allocator_type, true>();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -17,50 +17,15 @@
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// 20.4.1.1 allocator members
|
||||
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <ext/new_allocator.h>
|
||||
|
||||
static size_t count;
|
||||
|
||||
struct count_check
|
||||
{
|
||||
count_check() { }
|
||||
~count_check()
|
||||
{
|
||||
if (count != 0)
|
||||
throw std::runtime_error("allocation/deallocation count isn't zero");
|
||||
}
|
||||
};
|
||||
|
||||
static count_check check;
|
||||
|
||||
void* operator new(size_t size) throw(std::bad_alloc)
|
||||
{
|
||||
std::printf("operator new is called \n");
|
||||
void* p = std::malloc(size);
|
||||
if (p == NULL)
|
||||
throw std::bad_alloc();
|
||||
count++;
|
||||
return p;
|
||||
}
|
||||
|
||||
void operator delete(void* p) throw()
|
||||
{
|
||||
std::printf("operator delete is called \n");
|
||||
if (p == NULL)
|
||||
return;
|
||||
count--;
|
||||
}
|
||||
#include <replacement_memory_operators.h>
|
||||
|
||||
typedef char char_t;
|
||||
typedef std::char_traits<char_t> traits_t;
|
||||
typedef __gnu_cxx::new_allocator<char_t> allocator_t;
|
||||
typedef std::basic_string<char_t, traits_t, allocator_t> string_t;
|
||||
typedef std::basic_string<char_t, traits_t, allocator_t> string_t;
|
||||
|
||||
string_t s("bayou bend");
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
|
||||
// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
|
||||
// Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
@ -17,54 +17,23 @@
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// 20.4.1.1 allocator members
|
||||
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <ext/new_allocator.h>
|
||||
|
||||
static size_t count;
|
||||
|
||||
struct count_check
|
||||
{
|
||||
count_check() { }
|
||||
~count_check()
|
||||
{
|
||||
if (count != 0)
|
||||
throw std::runtime_error("allocation/deallocation count isn't zero");
|
||||
}
|
||||
};
|
||||
|
||||
static count_check check;
|
||||
|
||||
void* operator new(size_t size) throw(std::bad_alloc)
|
||||
{
|
||||
std::printf("operator new is called \n");
|
||||
void* p = std::malloc(size);
|
||||
if (p == NULL)
|
||||
throw std::bad_alloc();
|
||||
count++;
|
||||
return p;
|
||||
}
|
||||
|
||||
void operator delete(void* p) throw()
|
||||
{
|
||||
std::printf("operator delete is called \n");
|
||||
if (p == NULL)
|
||||
return;
|
||||
count--;
|
||||
}
|
||||
#include <replacement_memory_operators.h>
|
||||
|
||||
typedef char char_t;
|
||||
typedef std::char_traits<char_t> traits_t;
|
||||
typedef __gnu_cxx::new_allocator<char_t> allocator_t;
|
||||
typedef std::basic_string<char_t, traits_t, allocator_t> string_t;
|
||||
typedef std::basic_string<char_t, traits_t, allocator_t> string_t;
|
||||
|
||||
int main()
|
||||
{
|
||||
string_t s;
|
||||
s += "bayou bend";
|
||||
{
|
||||
string_t s;
|
||||
s += "bayou bend";
|
||||
}
|
||||
|
||||
if (__gnu_test::counter::count() != 0)
|
||||
throw std::runtime_error("count not zero");
|
||||
return 0;
|
||||
}
|
||||
|
@ -21,36 +21,12 @@
|
||||
|
||||
#include <cstdlib>
|
||||
#include <ext/pool_allocator.h>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_allocator.h>
|
||||
|
||||
using __gnu_cxx::__pool_alloc;
|
||||
|
||||
void*
|
||||
operator new(std::size_t n) throw(std::bad_alloc)
|
||||
{
|
||||
new_called = true;
|
||||
return std::malloc(n);
|
||||
}
|
||||
|
||||
void
|
||||
operator delete(void *v) throw()
|
||||
{
|
||||
delete_called = true;
|
||||
return std::free(v);
|
||||
}
|
||||
|
||||
void test01()
|
||||
{
|
||||
// Uses new, but delete only sometimes.
|
||||
bool test __attribute__((unused)) = true;
|
||||
typedef __pool_alloc<unsigned int> allocator_type;
|
||||
VERIFY( bool(__gnu_test::check_delete<allocator_type, false>()) );
|
||||
}
|
||||
#include <replacement_memory_operators.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
// Uses new, but delete only sometimes.
|
||||
typedef __gnu_cxx::__pool_alloc<unsigned int> allocator_type;
|
||||
__gnu_test::check_delete<allocator_type, false>();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -21,35 +21,11 @@
|
||||
|
||||
#include <cstdlib>
|
||||
#include <ext/pool_allocator.h>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_allocator.h>
|
||||
|
||||
using __gnu_cxx::__pool_alloc;
|
||||
|
||||
void*
|
||||
operator new(std::size_t n) throw(std::bad_alloc)
|
||||
{
|
||||
new_called = true;
|
||||
return std::malloc(n);
|
||||
}
|
||||
|
||||
void
|
||||
operator delete(void *v) throw()
|
||||
{
|
||||
delete_called = true;
|
||||
return std::free(v);
|
||||
}
|
||||
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
typedef __pool_alloc<unsigned int> allocator_type;
|
||||
VERIFY( bool(__gnu_test::check_new<allocator_type, true>()) );
|
||||
}
|
||||
#include <replacement_memory_operators.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
{
|
||||
typedef __gnu_cxx::__pool_alloc<unsigned int> allocator_type;
|
||||
__gnu_test::check_new<allocator_type, true>();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -20,36 +20,11 @@
|
||||
|
||||
#include <cstdlib>
|
||||
#include <ext/throw_allocator.h>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_allocator.h>
|
||||
|
||||
using __gnu_cxx::throw_allocator;
|
||||
|
||||
void*
|
||||
operator new(std::size_t n) throw(std::bad_alloc)
|
||||
{
|
||||
new_called = true;
|
||||
return std::malloc(n);
|
||||
}
|
||||
|
||||
void
|
||||
operator delete(void *v) throw()
|
||||
{
|
||||
delete_called = true;
|
||||
return std::free(v);
|
||||
}
|
||||
|
||||
// These just help tracking down error messages.
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
typedef throw_allocator<unsigned int> allocator_type;
|
||||
VERIFY( bool(__gnu_test::check_delete<allocator_type, true>()) );
|
||||
}
|
||||
#include <replacement_memory_operators.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
{
|
||||
typedef __gnu_cxx::throw_allocator<unsigned int> allocator_type;
|
||||
__gnu_test::check_delete<allocator_type, true>();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -20,36 +20,11 @@
|
||||
|
||||
#include <cstdlib>
|
||||
#include <ext/throw_allocator.h>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_allocator.h>
|
||||
|
||||
using __gnu_cxx::throw_allocator;
|
||||
|
||||
void*
|
||||
operator new(std::size_t n) throw(std::bad_alloc)
|
||||
{
|
||||
new_called = true;
|
||||
return std::malloc(n);
|
||||
}
|
||||
|
||||
void
|
||||
operator delete(void *v) throw()
|
||||
{
|
||||
delete_called = true;
|
||||
return std::free(v);
|
||||
}
|
||||
|
||||
// These just help tracking down error messages.
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
typedef throw_allocator<unsigned int> allocator_type;
|
||||
VERIFY( bool(__gnu_test::check_new<allocator_type, true>()) );
|
||||
}
|
||||
#include <replacement_memory_operators.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
{
|
||||
typedef __gnu_cxx::throw_allocator<unsigned int> allocator_type;
|
||||
__gnu_test::check_new<allocator_type, true>();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -21,50 +21,12 @@
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <ext/throw_allocator.h>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
static size_t count;
|
||||
|
||||
struct count_check
|
||||
{
|
||||
count_check() {}
|
||||
~count_check()
|
||||
{
|
||||
if (count != 0)
|
||||
throw std::runtime_error("count isn't zero");
|
||||
}
|
||||
};
|
||||
|
||||
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--;
|
||||
if (count == 0)
|
||||
printf("All memory released \n");
|
||||
else
|
||||
printf("%lu allocations to be released \n",
|
||||
static_cast<unsigned long>(count));
|
||||
free(p);
|
||||
}
|
||||
#include <replacement_memory_operators.h>
|
||||
|
||||
typedef char char_t;
|
||||
typedef std::char_traits<char_t> traits_t;
|
||||
typedef __gnu_cxx::throw_allocator<char_t> allocator_t;
|
||||
typedef std::basic_string<char_t, traits_t, allocator_t> string_t;
|
||||
typedef std::basic_string<char_t, traits_t, allocator_t> string_t;
|
||||
|
||||
string_t s("bayou bend");
|
||||
|
||||
|
@ -20,46 +20,21 @@
|
||||
|
||||
#include <string>
|
||||
#include <ext/throw_allocator.h>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
static size_t alloc_cnt;
|
||||
|
||||
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();
|
||||
alloc_cnt++;
|
||||
return p;
|
||||
}
|
||||
|
||||
void operator delete(void* p) throw()
|
||||
{
|
||||
printf("operator delete is called \n");
|
||||
if (p == NULL)
|
||||
return;
|
||||
alloc_cnt--;
|
||||
if (alloc_cnt == 0)
|
||||
printf("All memory released \n");
|
||||
else
|
||||
printf("%lu allocations to be released \n",
|
||||
static_cast<unsigned long>(alloc_cnt));
|
||||
free(p);
|
||||
}
|
||||
#include <replacement_memory_operators.h>
|
||||
|
||||
typedef char char_t;
|
||||
typedef std::char_traits<char_t> traits_t;
|
||||
typedef __gnu_cxx::throw_allocator<char_t> allocator_t;
|
||||
typedef std::basic_string<char_t, traits_t, allocator_t> string_t;
|
||||
typedef std::basic_string<char_t, traits_t, allocator_t> string_t;
|
||||
|
||||
int main()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
{
|
||||
string_t s;
|
||||
s += "bayou bend";
|
||||
}
|
||||
VERIFY( alloc_cnt == 0 );
|
||||
|
||||
if (__gnu_test::counter::count() != 0)
|
||||
throw std::runtime_error("count not zero");
|
||||
return 0;
|
||||
}
|
||||
|
110
libstdc++-v3/testsuite/util/replacement_memory_operators.h
Normal file
110
libstdc++-v3/testsuite/util/replacement_memory_operators.h
Normal file
@ -0,0 +1,110 @@
|
||||
//
|
||||
// Copyright (C) 2007, 2009 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
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <exception>
|
||||
|
||||
namespace __gnu_test
|
||||
{
|
||||
struct counter_error : public std::exception { };
|
||||
|
||||
struct counter
|
||||
{
|
||||
size_t _M_count;
|
||||
bool _M_throw;
|
||||
|
||||
counter() : _M_count(0), _M_throw(true) { }
|
||||
|
||||
~counter()
|
||||
{
|
||||
if (_M_throw && _M_count != 0)
|
||||
throw counter_error();
|
||||
}
|
||||
|
||||
static void
|
||||
increment() { get()._M_count++; }
|
||||
|
||||
static void
|
||||
decrement() { get()._M_count--; }
|
||||
|
||||
static counter&
|
||||
get()
|
||||
{
|
||||
static counter g;
|
||||
return g;
|
||||
}
|
||||
|
||||
static size_t
|
||||
count() { return get()._M_count; }
|
||||
|
||||
static void
|
||||
exceptions(bool __b) { get()._M_throw = __b; }
|
||||
};
|
||||
|
||||
template<typename Alloc, bool uses_global_new>
|
||||
bool
|
||||
check_new(Alloc a = Alloc())
|
||||
{
|
||||
__gnu_test::counter::exceptions(false);
|
||||
a.allocate(10);
|
||||
const bool __b((__gnu_test::counter::count() > 0) == uses_global_new);
|
||||
if (!__b)
|
||||
throw std::logic_error("counter not incremented");
|
||||
return __b;
|
||||
}
|
||||
|
||||
template<typename Alloc, bool uses_global_delete>
|
||||
bool
|
||||
check_delete(Alloc a = Alloc())
|
||||
{
|
||||
__gnu_test::counter::exceptions(false);
|
||||
typename Alloc::pointer p = a.allocate(10);
|
||||
const std::size_t count1 = __gnu_test::counter::count();
|
||||
a.deallocate(p, 10);
|
||||
const std::size_t count2 = __gnu_test::counter::count();
|
||||
const bool __b((count2 < count1) == uses_global_delete);
|
||||
if (!__b)
|
||||
throw std::logic_error("counter not decremented");
|
||||
return __b;
|
||||
}
|
||||
} // namespace __gnu_test
|
||||
|
||||
void* operator new(std::size_t size) throw(std::bad_alloc)
|
||||
{
|
||||
printf("operator new is called \n");
|
||||
void* p = std::malloc(size);
|
||||
if (p == NULL)
|
||||
throw std::bad_alloc();
|
||||
__gnu_test::counter::increment();
|
||||
return p;
|
||||
}
|
||||
|
||||
void operator delete(void* p) throw()
|
||||
{
|
||||
printf("operator delete is called \n");
|
||||
if (p != NULL)
|
||||
{
|
||||
std::free(p);
|
||||
__gnu_test::counter::decrement();
|
||||
|
||||
std::size_t count = __gnu_test::counter::count();
|
||||
if (count == 0)
|
||||
printf("All memory released \n");
|
||||
else
|
||||
printf("%lu allocations to be released \n", count);
|
||||
}
|
||||
}
|
@ -32,12 +32,6 @@
|
||||
#include <cassert>
|
||||
#include <bits/move.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
bool new_called = false;
|
||||
bool delete_called = false;
|
||||
}
|
||||
|
||||
namespace __gnu_test
|
||||
{
|
||||
class tracker_allocator_counter
|
||||
@ -186,27 +180,6 @@ namespace __gnu_test
|
||||
bool
|
||||
check_construct_destroy(const char* tag, int expected_c, int expected_d);
|
||||
|
||||
template<typename Alloc, bool uses_global_new>
|
||||
bool
|
||||
check_new(Alloc a = Alloc())
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
a.allocate(10);
|
||||
test &= ( new_called == uses_global_new );
|
||||
return test;
|
||||
}
|
||||
|
||||
template<typename Alloc, bool uses_global_delete>
|
||||
bool
|
||||
check_delete(Alloc a = Alloc())
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
typename Alloc::pointer p = a.allocate(10);
|
||||
a.deallocate(p, 10);
|
||||
test &= ( delete_called == uses_global_delete );
|
||||
return test;
|
||||
}
|
||||
|
||||
template<typename Alloc>
|
||||
bool
|
||||
check_deallocate_null()
|
||||
|
@ -217,7 +217,7 @@ namespace __gnu_test
|
||||
#endif
|
||||
}
|
||||
|
||||
counter::size_type counter::count = 0;
|
||||
object_counter::size_type object_counter::count = 0;
|
||||
unsigned int copy_constructor::count_ = 0;
|
||||
unsigned int copy_constructor::throw_on_ = 0;
|
||||
unsigned int assignment_operator::count_ = 0;
|
||||
|
@ -34,8 +34,8 @@
|
||||
// limit in megabytes (a floating-point number). If _GLIBCXX_RES_LIMITS is
|
||||
// not #defined before including this header, then no limiting is attempted.
|
||||
//
|
||||
// 3) counter
|
||||
// This is a POD with a static data member, gnu_counting_struct::count,
|
||||
// 3) object_counter
|
||||
// This is a POD with a static data member, object_counter::count,
|
||||
// which starts at zero, increments on instance construction, and decrements
|
||||
// on instance destruction. "assert_count(n)" can be called to VERIFY()
|
||||
// that the count equals N.
|
||||
@ -135,19 +135,19 @@ namespace __gnu_test
|
||||
run_tests_wrapped_env(const char*, const char*, const func_callback&);
|
||||
|
||||
// Counting.
|
||||
struct counter
|
||||
struct object_counter
|
||||
{
|
||||
// Specifically and glaringly-obviously marked 'signed' so that when
|
||||
// COUNT mistakenly goes negative, we can track the patterns of
|
||||
// deletions more easily.
|
||||
// Specifically and glaringly-obviously marked 'signed' so that
|
||||
// when COUNT mistakenly goes negative, we can track the patterns
|
||||
// of deletions more easily.
|
||||
typedef signed int size_type;
|
||||
static size_type count;
|
||||
counter() { ++count; }
|
||||
counter (const counter&) { ++count; }
|
||||
~counter() { --count; }
|
||||
object_counter() { ++count; }
|
||||
object_counter (const object_counter&) { ++count; }
|
||||
~object_counter() { --count; }
|
||||
};
|
||||
|
||||
#define assert_count(n) VERIFY(__gnu_test::counter::count == n)
|
||||
#define assert_count(n) VERIFY(__gnu_test::object_counter::count == n)
|
||||
|
||||
// A (static) class for counting copy constructors and possibly throwing an
|
||||
// exception on a desired count.
|
||||
|
Loading…
x
Reference in New Issue
Block a user