|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r67958 - in branches/release: boost/pool boost/pool/detail libs/pool libs/pool/test
From: marshall_at_[hidden]
Date: 2011-01-11 09:22:34
Author: marshall
Date: 2011-01-11 09:22:32 EST (Tue, 11 Jan 2011)
New Revision: 67958
URL: http://svn.boost.org/trac/boost/changeset/67958
Log:
Merging fixes to release; Fixes #2696; Refs #4346; Refs #2941; Refs #386
Properties modified:
branches/release/boost/pool/ (props changed)
branches/release/libs/pool/ (props changed)
Text files modified:
branches/release/boost/pool/detail/pool_construct.inc | 343 +++++++++++++++++++--------------------
branches/release/boost/pool/detail/pool_construct.m4 | 4
branches/release/boost/pool/detail/pool_construct_simple.inc | 12
branches/release/boost/pool/detail/pool_construct_simple.m4 | 11
branches/release/boost/pool/object_pool.hpp | 16
branches/release/boost/pool/pool.hpp | 74 +++++---
branches/release/boost/pool/pool_alloc.hpp | 62 +++---
branches/release/boost/pool/poolfwd.hpp | 9
branches/release/boost/pool/simple_segregated_storage.hpp | 14 +
branches/release/boost/pool/singleton_pool.hpp | 15
branches/release/libs/pool/test/test_pool_alloc.cpp | 21 +
11 files changed, 309 insertions(+), 272 deletions(-)
Modified: branches/release/boost/pool/detail/pool_construct.inc
==============================================================================
--- branches/release/boost/pool/detail/pool_construct.inc (original)
+++ branches/release/boost/pool/detail/pool_construct.inc 2011-01-11 09:22:32 EST (Tue, 11 Jan 2011)
@@ -1,853 +1,852 @@
// Copyright (C) 2000 Stephen Cleary
//
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
+// Distributed under the Boost Software License, Version 1.0. (See accompany-
+// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org for updates, documentation, and revision history.
-// This file was AUTOMATICALLY GENERATED from "pool_c~1.m4"
+// This file was AUTOMATICALLY GENERATED from "stdin"
// Do NOT include directly!
// Do NOT edit!
template <typename T0>
element_type * construct(T0 & a0)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0>
element_type * construct(const T0 & a0)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0>
element_type * construct(volatile T0 & a0)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0>
element_type * construct(const volatile T0 & a0)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1>
element_type * construct(T0 & a0, T1 & a1)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1>
element_type * construct(const T0 & a0, T1 & a1)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1>
element_type * construct(volatile T0 & a0, T1 & a1)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1>
element_type * construct(const volatile T0 & a0, T1 & a1)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1>
element_type * construct(T0 & a0, const T1 & a1)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1>
element_type * construct(const T0 & a0, const T1 & a1)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1>
element_type * construct(volatile T0 & a0, const T1 & a1)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1>
element_type * construct(const volatile T0 & a0, const T1 & a1)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1>
element_type * construct(T0 & a0, volatile T1 & a1)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1>
element_type * construct(const T0 & a0, volatile T1 & a1)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1>
element_type * construct(volatile T0 & a0, volatile T1 & a1)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1>
element_type * construct(const volatile T0 & a0, volatile T1 & a1)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1>
element_type * construct(T0 & a0, const volatile T1 & a1)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1>
element_type * construct(const T0 & a0, const volatile T1 & a1)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1>
element_type * construct(volatile T0 & a0, const volatile T1 & a1)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1>
element_type * construct(const volatile T0 & a0, const volatile T1 & a1)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(T0 & a0, T1 & a1, T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const T0 & a0, T1 & a1, T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(volatile T0 & a0, T1 & a1, T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const volatile T0 & a0, T1 & a1, T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(T0 & a0, const T1 & a1, T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const T0 & a0, const T1 & a1, T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(volatile T0 & a0, const T1 & a1, T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const volatile T0 & a0, const T1 & a1, T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(T0 & a0, volatile T1 & a1, T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const T0 & a0, volatile T1 & a1, T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(volatile T0 & a0, volatile T1 & a1, T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const volatile T0 & a0, volatile T1 & a1, T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(T0 & a0, const volatile T1 & a1, T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const T0 & a0, const volatile T1 & a1, T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(volatile T0 & a0, const volatile T1 & a1, T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const volatile T0 & a0, const volatile T1 & a1, T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(T0 & a0, T1 & a1, const T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const T0 & a0, T1 & a1, const T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(volatile T0 & a0, T1 & a1, const T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const volatile T0 & a0, T1 & a1, const T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(T0 & a0, const T1 & a1, const T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const T0 & a0, const T1 & a1, const T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(volatile T0 & a0, const T1 & a1, const T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const volatile T0 & a0, const T1 & a1, const T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(T0 & a0, volatile T1 & a1, const T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const T0 & a0, volatile T1 & a1, const T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(volatile T0 & a0, volatile T1 & a1, const T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const volatile T0 & a0, volatile T1 & a1, const T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(T0 & a0, const volatile T1 & a1, const T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const T0 & a0, const volatile T1 & a1, const T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(volatile T0 & a0, const volatile T1 & a1, const T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const volatile T0 & a0, const volatile T1 & a1, const T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(T0 & a0, T1 & a1, volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const T0 & a0, T1 & a1, volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(volatile T0 & a0, T1 & a1, volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const volatile T0 & a0, T1 & a1, volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(T0 & a0, const T1 & a1, volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const T0 & a0, const T1 & a1, volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(volatile T0 & a0, const T1 & a1, volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const volatile T0 & a0, const T1 & a1, volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(T0 & a0, volatile T1 & a1, volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const T0 & a0, volatile T1 & a1, volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(volatile T0 & a0, volatile T1 & a1, volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const volatile T0 & a0, volatile T1 & a1, volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(T0 & a0, const volatile T1 & a1, volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const T0 & a0, const volatile T1 & a1, volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(volatile T0 & a0, const volatile T1 & a1, volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const volatile T0 & a0, const volatile T1 & a1, volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(T0 & a0, T1 & a1, const volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const T0 & a0, T1 & a1, const volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(volatile T0 & a0, T1 & a1, const volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const volatile T0 & a0, T1 & a1, const volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(T0 & a0, const T1 & a1, const volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const T0 & a0, const T1 & a1, const volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(volatile T0 & a0, const T1 & a1, const volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const volatile T0 & a0, const T1 & a1, const volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(T0 & a0, volatile T1 & a1, const volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const T0 & a0, volatile T1 & a1, const volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(volatile T0 & a0, volatile T1 & a1, const volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const volatile T0 & a0, volatile T1 & a1, const volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(T0 & a0, const volatile T1 & a1, const volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const T0 & a0, const volatile T1 & a1, const volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(volatile T0 & a0, const volatile T1 & a1, const volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const volatile T0 & a0, const volatile T1 & a1, const volatile T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
Modified: branches/release/boost/pool/detail/pool_construct.m4
==============================================================================
--- branches/release/boost/pool/detail/pool_construct.m4 (original)
+++ branches/release/boost/pool/detail/pool_construct.m4 2011-01-11 09:22:32 EST (Tue, 11 Jan 2011)
@@ -74,11 +74,11 @@
element_type * construct(BOOST_M4_FOR(i, 0, N,
`cv_qual(m4_eval((cv >> (i * 2)) % 4))T`'i & a`'i', `, '))
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(BOOST_M4_FOR(i, 0, N, `a`'i', `, ')); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
')')
Modified: branches/release/boost/pool/detail/pool_construct_simple.inc
==============================================================================
--- branches/release/boost/pool/detail/pool_construct_simple.inc (original)
+++ branches/release/boost/pool/detail/pool_construct_simple.inc 2011-01-11 09:22:32 EST (Tue, 11 Jan 2011)
@@ -13,31 +13,31 @@
template <typename T0>
element_type * construct(const T0 & a0)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1>
element_type * construct(const T0 & a0, const T1 & a1)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
template <typename T0, typename T1, typename T2>
element_type * construct(const T0 & a0, const T1 & a1, const T2 & a2)
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(a0, a1, a2); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
Modified: branches/release/boost/pool/detail/pool_construct_simple.m4
==============================================================================
--- branches/release/boost/pool/detail/pool_construct_simple.m4 (original)
+++ branches/release/boost/pool/detail/pool_construct_simple.m4 2011-01-11 09:22:32 EST (Tue, 11 Jan 2011)
@@ -40,10 +40,9 @@
m4_dnl
// Copyright (C) 2000 Stephen Cleary
//
-// This file can be redistributed and/or modified under the terms found
-// in "copyright.html"
-// This software and its documentation is provided "as is" without express or
-// implied warranty, and with no claim as to its suitability for any purpose.
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org for updates, documentation, and revision history.
@@ -63,11 +62,11 @@
element_type * construct(BOOST_M4_FOR(i, 0, N,
`const T`'i & a`'i', `, '))
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(BOOST_M4_FOR(i, 0, N, `a`'i', `, ')); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
')
Modified: branches/release/boost/pool/object_pool.hpp
==============================================================================
--- branches/release/boost/pool/object_pool.hpp (original)
+++ branches/release/boost/pool/object_pool.hpp 2011-01-11 09:22:32 EST (Tue, 11 Jan 2011)
@@ -53,26 +53,26 @@
public:
// This constructor parameter is an extension!
- explicit object_pool(const size_type next_size = 32)
- :pool<UserAllocator>(sizeof(T), next_size) { }
+ explicit object_pool(const size_type next_size = 32, const size_type max_size = 0)
+ :pool<UserAllocator>(sizeof(T), next_size, max_size) { }
~object_pool();
// Returns 0 if out-of-memory
- element_type * malloc()
+ element_type * malloc BOOST_PREVENT_MACRO_SUBSTITUTION()
{ return static_cast<element_type *>(store().ordered_malloc()); }
- void free(element_type * const chunk)
+ void free BOOST_PREVENT_MACRO_SUBSTITUTION(element_type * const chunk)
{ store().ordered_free(chunk); }
bool is_from(element_type * const chunk) const
{ return store().is_from(chunk); }
element_type * construct()
{
- element_type * const ret = malloc();
+ element_type * const ret = (malloc)();
if (ret == 0)
return ret;
try { new (ret) element_type(); }
- catch (...) { free(ret); throw; }
+ catch (...) { (free)(ret); throw; }
return ret;
}
@@ -87,7 +87,7 @@
void destroy(element_type * const chunk)
{
chunk->~T();
- free(chunk);
+ (free)(chunk);
}
// These functions are extensions!
@@ -136,7 +136,7 @@
}
// free storage
- UserAllocator::free(iter.begin());
+ (UserAllocator::free)(iter.begin());
// increment iter
iter = next;
Modified: branches/release/boost/pool/pool.hpp
==============================================================================
--- branches/release/boost/pool/pool.hpp (original)
+++ branches/release/boost/pool/pool.hpp 2011-01-11 09:22:32 EST (Tue, 11 Jan 2011)
@@ -51,9 +51,9 @@
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
- static char * malloc(const size_type bytes)
+ static char * malloc BOOST_PREVENT_MACRO_SUBSTITUTION(const size_type bytes)
{ return new (std::nothrow) char[bytes]; }
- static void free(char * const block)
+ static void free BOOST_PREVENT_MACRO_SUBSTITUTION(char * const block)
{ delete [] block; }
};
@@ -62,9 +62,9 @@
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
- static char * malloc(const size_type bytes)
- { return reinterpret_cast<char *>(std::malloc(bytes)); }
- static void free(char * const block)
+ static char * malloc BOOST_PREVENT_MACRO_SUBSTITUTION(const size_type bytes)
+ { return static_cast<char *>(std::malloc(bytes)); }
+ static void free BOOST_PREVENT_MACRO_SUBSTITUTION(char * const block)
{ std::free(block); }
};
@@ -113,9 +113,11 @@
}
size_type & next_size() const
- { return *(reinterpret_cast<size_type *>(ptr_next_size())); }
+ {
+ return *(static_cast<size_type *>(static_cast<void*>((ptr_next_size()))));
+ }
char * & next_ptr() const
- { return *(reinterpret_cast<char **>(ptr_next_ptr())); }
+ { return *(static_cast<char **>(static_cast<void*>(ptr_next_ptr()))); }
PODptr next() const
{ return PODptr<size_type>(next_ptr(), next_size()); }
@@ -154,6 +156,7 @@
const size_type requested_size;
size_type next_size;
size_type start_size;
+ size_type max_size;
// finds which POD in the list 'chunk' was allocated from
details::PODptr<size_type> find_POD(void * const chunk) const;
@@ -192,8 +195,9 @@
// The second parameter here is an extension!
// pre: npartition_size != 0 && nnext_size != 0
explicit pool(const size_type nrequested_size,
- const size_type nnext_size = 32)
- :list(0, 0), requested_size(nrequested_size), next_size(nnext_size), start_size(nnext_size)
+ const size_type nnext_size = 32,
+ const size_type nmax_size = 0)
+ :list(0, 0), requested_size(nrequested_size), next_size(nnext_size), start_size(nnext_size),max_size(nmax_size)
{ }
~pool() { purge_memory(); }
@@ -210,17 +214,19 @@
// These functions are extensions!
size_type get_next_size() const { return next_size; }
void set_next_size(const size_type nnext_size) { next_size = start_size = nnext_size; }
+ size_type get_max_size() const { return max_size; }
+ void set_max_size(const size_type nmax_size) { max_size = nmax_size; }
size_type get_requested_size() const { return requested_size; }
// Both malloc and ordered_malloc do a quick inlined check first for any
// free chunks. Only if we need to get another memory block do we call
// the non-inlined *_need_resize() functions.
// Returns 0 if out-of-memory
- void * malloc()
+ void * malloc BOOST_PREVENT_MACRO_SUBSTITUTION()
{
// Look for a non-empty storage
if (!store().empty())
- return store().malloc();
+ return (store().malloc)();
return malloc_need_resize();
}
@@ -228,7 +234,7 @@
{
// Look for a non-empty storage
if (!store().empty())
- return store().malloc();
+ return (store().malloc)();
return ordered_malloc_need_resize();
}
@@ -238,8 +244,8 @@
// pre: 'chunk' must have been previously
// returned by *this.malloc().
- void free(void * const chunk)
- { store().free(chunk); }
+ void free BOOST_PREVENT_MACRO_SUBSTITUTION(void * const chunk)
+ { (store().free)(chunk); }
// pre: 'chunk' must have been previously
// returned by *this.malloc().
@@ -248,7 +254,7 @@
// pre: 'chunk' must have been previously
// returned by *this.malloc(n).
- void free(void * const chunks, const size_type n)
+ void free BOOST_PREVENT_MACRO_SUBSTITUTION(void * const chunks, const size_type n)
{
const size_type partition_size = alloc_size();
const size_type total_req_size = n * requested_size;
@@ -388,7 +394,7 @@
this->first = free_p;
// And release memory
- UserAllocator::free(ptr.begin());
+ (UserAllocator::free)(ptr.begin());
ret = true;
}
@@ -414,7 +420,7 @@
const details::PODptr<size_type> next = iter.next();
// delete the storage
- UserAllocator::free(iter.begin());
+ (UserAllocator::free)(iter.begin());
// increment iter
iter = next;
@@ -434,11 +440,16 @@
const size_type partition_size = alloc_size();
const size_type POD_size = next_size * partition_size +
details::pool::ct_lcm<sizeof(size_type), sizeof(void *)>::value + sizeof(size_type);
- char * const ptr = UserAllocator::malloc(POD_size);
+ char * const ptr = (UserAllocator::malloc)(POD_size);
if (ptr == 0)
return 0;
const details::PODptr<size_type> node(ptr, POD_size);
- next_size <<= 1;
+
+ BOOST_USING_STD_MIN();
+ if(!max_size)
+ next_size <<= 1;
+ else if( next_size*partition_size/requested_size < max_size)
+ next_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size*requested_size/ partition_size);
// initialize it,
store().add_block(node.begin(), node.element_size(), partition_size);
@@ -448,7 +459,7 @@
list = node;
// and return a chunk from it.
- return store().malloc();
+ return (store().malloc)();
}
template <typename UserAllocator>
@@ -458,17 +469,22 @@
const size_type partition_size = alloc_size();
const size_type POD_size = next_size * partition_size +
details::pool::ct_lcm<sizeof(size_type), sizeof(void *)>::value + sizeof(size_type);
- char * const ptr = UserAllocator::malloc(POD_size);
+ char * const ptr = (UserAllocator::malloc)(POD_size);
if (ptr == 0)
return 0;
const details::PODptr<size_type> node(ptr, POD_size);
- next_size <<= 1;
+
+ BOOST_USING_STD_MIN();
+ if(!max_size)
+ next_size <<= 1;
+ else if( next_size*partition_size/requested_size < max_size)
+ next_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size*requested_size/ partition_size);
// initialize it,
// (we can use "add_block" here because we know that
// the free list is empty, so we don't have to use
// the slower ordered version)
- store().add_block(node.begin(), node.element_size(), partition_size);
+ store().add_ordered_block(node.begin(), node.element_size(), partition_size);
// insert it into the list,
// handle border case
@@ -497,7 +513,7 @@
}
// and return a chunk from it.
- return store().malloc();
+ return (store().malloc)();
}
template <typename UserAllocator>
@@ -518,7 +534,7 @@
next_size = max BOOST_PREVENT_MACRO_SUBSTITUTION(next_size, num_chunks);
const size_type POD_size = next_size * partition_size +
details::pool::ct_lcm<sizeof(size_type), sizeof(void *)>::value + sizeof(size_type);
- char * const ptr = UserAllocator::malloc(POD_size);
+ char * const ptr = (UserAllocator::malloc)(POD_size);
if (ptr == 0)
return 0;
const details::PODptr<size_type> node(ptr, POD_size);
@@ -528,10 +544,14 @@
// the free list is empty, so we don't have to use
// the slower ordered version)
if (next_size > num_chunks)
- store().add_block(node.begin() + num_chunks * partition_size,
+ store().add_ordered_block(node.begin() + num_chunks * partition_size,
node.element_size() - num_chunks * partition_size, partition_size);
- next_size <<= 1;
+ BOOST_USING_STD_MIN();
+ if(!max_size)
+ next_size <<= 1;
+ else if( next_size*partition_size/requested_size < max_size)
+ next_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size*requested_size/ partition_size);
// insert it into the list,
// handle border case
Modified: branches/release/boost/pool/pool_alloc.hpp
==============================================================================
--- branches/release/boost/pool/pool_alloc.hpp (original)
+++ branches/release/boost/pool/pool_alloc.hpp 2011-01-11 09:22:32 EST (Tue, 11 Jan 2011)
@@ -35,7 +35,8 @@
template <typename T,
typename UserAllocator,
typename Mutex,
- unsigned NextSize>
+ unsigned NextSize,
+ unsigned MaxSize>
class pool_allocator
{
public:
@@ -54,7 +55,7 @@
template <typename U>
struct rebind
{
- typedef pool_allocator<U, UserAllocator, Mutex, NextSize> other;
+ typedef pool_allocator<U, UserAllocator, Mutex, NextSize,MaxSize> other;
};
public:
@@ -65,7 +66,7 @@
// initialization. See ticket #2359 for a complete explaination
// ( http://svn.boost.org/trac/boost/ticket/2359 )
singleton_pool<pool_allocator_tag, sizeof(T), UserAllocator, Mutex,
- NextSize>::is_from(0);
+ NextSize, MaxSize>::is_from(0);
}
// default copy constructor
@@ -74,14 +75,14 @@
// not explicit, mimicking std::allocator [20.4.1]
template <typename U>
- pool_allocator(const pool_allocator<U, UserAllocator, Mutex, NextSize> &)
+ pool_allocator(const pool_allocator<U, UserAllocator, Mutex, NextSize, MaxSize> &)
{
// Required to ensure construction of singleton_pool IFF an
// instace of this allocator is constructed during global
// initialization. See ticket #2359 for a complete explaination
// ( http://svn.boost.org/trac/boost/ticket/2359 )
singleton_pool<pool_allocator_tag, sizeof(T), UserAllocator, Mutex,
- NextSize>::is_from(0);
+ NextSize, MaxSize>::is_from(0);
}
// default destructor
@@ -109,7 +110,7 @@
{
const pointer ret = static_cast<pointer>(
singleton_pool<pool_allocator_tag, sizeof(T), UserAllocator, Mutex,
- NextSize>::ordered_malloc(n) );
+ NextSize, MaxSize>::ordered_malloc(n) );
if (ret == 0)
boost::throw_exception(std::bad_alloc());
return ret;
@@ -123,22 +124,23 @@
return;
#endif
singleton_pool<pool_allocator_tag, sizeof(T), UserAllocator, Mutex,
- NextSize>::ordered_free(ptr, n);
+ NextSize, MaxSize>::ordered_free(ptr, n);
}
};
template<
typename UserAllocator,
typename Mutex,
- unsigned NextSize>
-class pool_allocator<void, UserAllocator, Mutex, NextSize>
+ unsigned NextSize,
+ unsigned MaxSize>
+class pool_allocator<void, UserAllocator, Mutex, NextSize, MaxSize>
{
public:
typedef void* pointer;
typedef const void* const_pointer;
typedef void value_type;
template <class U> struct rebind {
- typedef pool_allocator<U, UserAllocator, Mutex, NextSize> other;
+ typedef pool_allocator<U, UserAllocator, Mutex, NextSize, MaxSize> other;
};
};
@@ -147,7 +149,8 @@
template <typename T,
typename UserAllocator,
typename Mutex,
- unsigned NextSize>
+ unsigned NextSize,
+ unsigned MaxSize>
class fast_pool_allocator
{
public:
@@ -166,7 +169,7 @@
template <typename U>
struct rebind
{
- typedef fast_pool_allocator<U, UserAllocator, Mutex, NextSize> other;
+ typedef fast_pool_allocator<U, UserAllocator, Mutex, NextSize, MaxSize> other;
};
public:
@@ -177,7 +180,7 @@
// initialization. See ticket #2359 for a complete explaination
// ( http://svn.boost.org/trac/boost/ticket/2359 )
singleton_pool<fast_pool_allocator_tag, sizeof(T),
- UserAllocator, Mutex, NextSize>::is_from(0);
+ UserAllocator, Mutex, NextSize, MaxSize>::is_from(0);
}
// default copy constructor
@@ -187,14 +190,14 @@
// not explicit, mimicking std::allocator [20.4.1]
template <typename U>
fast_pool_allocator(
- const fast_pool_allocator<U, UserAllocator, Mutex, NextSize> &)
+ const fast_pool_allocator<U, UserAllocator, Mutex, NextSize, MaxSize> &)
{
// Required to ensure construction of singleton_pool IFF an
// instace of this allocator is constructed during global
// initialization. See ticket #2359 for a complete explaination
// ( http://svn.boost.org/trac/boost/ticket/2359 )
singleton_pool<fast_pool_allocator_tag, sizeof(T),
- UserAllocator, Mutex, NextSize>::is_from(0);
+ UserAllocator, Mutex, NextSize, MaxSize>::is_from(0);
}
// default destructor
@@ -222,11 +225,11 @@
{
const pointer ret = (n == 1) ?
static_cast<pointer>(
- singleton_pool<fast_pool_allocator_tag, sizeof(T),
- UserAllocator, Mutex, NextSize>::malloc() ) :
+ (singleton_pool<fast_pool_allocator_tag, sizeof(T),
+ UserAllocator, Mutex, NextSize, MaxSize>::malloc)() ) :
static_cast<pointer>(
singleton_pool<fast_pool_allocator_tag, sizeof(T),
- UserAllocator, Mutex, NextSize>::ordered_malloc(n) );
+ UserAllocator, Mutex, NextSize, MaxSize>::ordered_malloc(n) );
if (ret == 0)
boost::throw_exception(std::bad_alloc());
return ret;
@@ -236,8 +239,8 @@
static pointer allocate()
{
const pointer ret = static_cast<pointer>(
- singleton_pool<fast_pool_allocator_tag, sizeof(T),
- UserAllocator, Mutex, NextSize>::malloc() );
+ (singleton_pool<fast_pool_allocator_tag, sizeof(T),
+ UserAllocator, Mutex, NextSize, MaxSize>::malloc)() );
if (ret == 0)
boost::throw_exception(std::bad_alloc());
return ret;
@@ -249,31 +252,32 @@
return;
#endif
if (n == 1)
- singleton_pool<fast_pool_allocator_tag, sizeof(T),
- UserAllocator, Mutex, NextSize>::free(ptr);
+ (singleton_pool<fast_pool_allocator_tag, sizeof(T),
+ UserAllocator, Mutex, NextSize, MaxSize>::free)(ptr);
else
- singleton_pool<fast_pool_allocator_tag, sizeof(T),
- UserAllocator, Mutex, NextSize>::free(ptr, n);
+ (singleton_pool<fast_pool_allocator_tag, sizeof(T),
+ UserAllocator, Mutex, NextSize, MaxSize>::free)(ptr, n);
}
static void deallocate(const pointer ptr)
{
- singleton_pool<fast_pool_allocator_tag, sizeof(T),
- UserAllocator, Mutex, NextSize>::free(ptr);
+ (singleton_pool<fast_pool_allocator_tag, sizeof(T),
+ UserAllocator, Mutex, NextSize, MaxSize>::free)(ptr);
}
};
template<
typename UserAllocator,
typename Mutex,
- unsigned NextSize>
-class fast_pool_allocator<void, UserAllocator, Mutex, NextSize>
+ unsigned NextSize,
+ unsigned MaxSize>
+class fast_pool_allocator<void, UserAllocator, Mutex, NextSize, MaxSize>
{
public:
typedef void* pointer;
typedef const void* const_pointer;
typedef void value_type;
template <class U> struct rebind {
- typedef fast_pool_allocator<U, UserAllocator, Mutex, NextSize> other;
+ typedef fast_pool_allocator<U, UserAllocator, Mutex, NextSize, MaxSize> other;
};
};
Modified: branches/release/boost/pool/poolfwd.hpp
==============================================================================
--- branches/release/boost/pool/poolfwd.hpp (original)
+++ branches/release/boost/pool/poolfwd.hpp 2011-01-11 09:22:32 EST (Tue, 11 Jan 2011)
@@ -46,7 +46,8 @@
template <typename Tag, unsigned RequestedSize,
typename UserAllocator = default_user_allocator_new_delete,
typename Mutex = details::pool::default_mutex,
- unsigned NextSize = 32>
+ unsigned NextSize = 32,
+ unsigned MaxSize = 0>
struct singleton_pool;
//
@@ -57,7 +58,8 @@
template <typename T,
typename UserAllocator = default_user_allocator_new_delete,
typename Mutex = details::pool::default_mutex,
- unsigned NextSize = 32>
+ unsigned NextSize = 32,
+ unsigned MaxSize = 0>
class pool_allocator;
struct fast_pool_allocator_tag;
@@ -65,7 +67,8 @@
template <typename T,
typename UserAllocator = default_user_allocator_new_delete,
typename Mutex = details::pool::default_mutex,
- unsigned NextSize = 32>
+ unsigned NextSize = 32,
+ unsigned MaxSize = 0>
class fast_pool_allocator;
} // namespace boost
Modified: branches/release/boost/pool/simple_segregated_storage.hpp
==============================================================================
--- branches/release/boost/pool/simple_segregated_storage.hpp (original)
+++ branches/release/boost/pool/simple_segregated_storage.hpp 2011-01-11 09:22:32 EST (Tue, 11 Jan 2011)
@@ -96,7 +96,7 @@
bool empty() const { return (first == 0); }
// pre: !empty()
- void * malloc()
+ void * malloc BOOST_PREVENT_MACRO_SUBSTITUTION()
{
void * const ret = first;
@@ -108,7 +108,7 @@
// pre: chunk was previously returned from a malloc() referring to the
// same free list
// post: !empty()
- void free(void * const chunk)
+ void free BOOST_PREVENT_MACRO_SUBSTITUTION(void * const chunk)
{
nextof(chunk) = first;
first = chunk;
@@ -127,7 +127,7 @@
// Place either at beginning or in middle/end
if (loc == 0)
- free(chunk);
+ (free)(chunk);
else
{
nextof(chunk) = nextof(loc);
@@ -147,7 +147,8 @@
void free_n(void * const chunks, const size_type n,
const size_type partition_size)
{
- add_block(chunks, n * partition_size, partition_size);
+ if(n != 0)
+ add_block(chunks, n * partition_size, partition_size);
}
// pre: chunks was previously allocated from *this with the same
@@ -156,7 +157,8 @@
void ordered_free_n(void * const chunks, const size_type n,
const size_type partition_size)
{
- add_ordered_block(chunks, n * partition_size, partition_size);
+ if(n != 0)
+ add_ordered_block(chunks, n * partition_size, partition_size);
}
};
@@ -247,6 +249,8 @@
void * simple_segregated_storage<SizeType>::malloc_n(const size_type n,
const size_type partition_size)
{
+ if(n == 0)
+ return 0;
void * start = &first;
void * iter;
do
Modified: branches/release/boost/pool/singleton_pool.hpp
==============================================================================
--- branches/release/boost/pool/singleton_pool.hpp (original)
+++ branches/release/boost/pool/singleton_pool.hpp 2011-01-11 09:22:32 EST (Tue, 11 Jan 2011)
@@ -27,7 +27,8 @@
template <typename Tag, unsigned RequestedSize,
typename UserAllocator,
typename Mutex,
- unsigned NextSize>
+ unsigned NextSize,
+ unsigned MaxSize>
struct singleton_pool
{
public:
@@ -52,11 +53,11 @@
singleton_pool();
public:
- static void * malloc()
+ static void * malloc BOOST_PREVENT_MACRO_SUBSTITUTION()
{
pool_type & p = singleton::instance();
details::pool::guard<Mutex> g(p);
- return p.p.malloc();
+ return (p.p.malloc)();
}
static void * ordered_malloc()
{
@@ -76,11 +77,11 @@
details::pool::guard<Mutex> g(p);
return p.p.is_from(ptr);
}
- static void free(void * const ptr)
+ static void free BOOST_PREVENT_MACRO_SUBSTITUTION(void * const ptr)
{
pool_type & p = singleton::instance();
details::pool::guard<Mutex> g(p);
- p.p.free(ptr);
+ (p.p.free)(ptr);
}
static void ordered_free(void * const ptr)
{
@@ -88,11 +89,11 @@
details::pool::guard<Mutex> g(p);
p.p.ordered_free(ptr);
}
- static void free(void * const ptr, const size_type n)
+ static void free BOOST_PREVENT_MACRO_SUBSTITUTION(void * const ptr, const size_type n)
{
pool_type & p = singleton::instance();
details::pool::guard<Mutex> g(p);
- p.p.free(ptr, n);
+ (p.p.free)(ptr, n);
}
static void ordered_free(void * const ptr, const size_type n)
{
Modified: branches/release/libs/pool/test/test_pool_alloc.cpp
==============================================================================
--- branches/release/libs/pool/test/test_pool_alloc.cpp (original)
+++ branches/release/libs/pool/test/test_pool_alloc.cpp 2011-01-11 09:22:32 EST (Tue, 11 Jan 2011)
@@ -215,6 +215,13 @@
// clean up memory leak
tmp->~tester();
boost::pool_allocator<tester>::deallocate(tmp, 1);
+
+ // test allocating zero elements
+ {
+ boost::pool_allocator<tester> alloc;
+ tester* ip = alloc.allocate(0);
+ alloc.deallocate(ip, 0);
+ }
}
// This is a wrapper around a UserAllocator. It just registers alloc/dealloc
@@ -229,18 +236,18 @@
static std::set<char *> allocated_blocks;
- static char * malloc(const size_type bytes)
+ static char * malloc BOOST_PREVENT_MACRO_SUBSTITUTION(const size_type bytes)
{
- char * const ret = UserAllocator::malloc(bytes);
+ char * const ret = (UserAllocator::malloc)(bytes);
allocated_blocks.insert(ret);
return ret;
}
- static void free(char * const block)
+ static void free BOOST_PREVENT_MACRO_SUBSTITUTION(char * const block)
{
if (allocated_blocks.find(block) == allocated_blocks.end())
std::cout << "Free'd non-malloc'ed block: " << (void *) block << std::endl;
allocated_blocks.erase(block);
- UserAllocator::free(block);
+ (UserAllocator::free)(block);
}
static bool ok() { return allocated_blocks.empty(); }
@@ -269,7 +276,7 @@
std::cout << "Pool purged memory" << std::endl;
// Should allocate from system
- pool.free(pool.malloc());
+ (pool.free)((pool.malloc)());
if (track_alloc::ok())
std::cout << "Memory error" << std::endl;
@@ -280,7 +287,7 @@
std::cout << "Memory error" << std::endl;
// Should allocate from system again
- pool.malloc(); // loses the pointer to the returned chunk (*A*)
+ (pool.malloc)(); // loses the pointer to the returned chunk (*A*)
// Ask pool to give up memory it's not using; this should fail
if (pool.release_memory())
@@ -294,7 +301,7 @@
std::cout << "Memory error" << std::endl;
// Should allocate from system again
- pool.malloc(); // loses the pointer to the returned chunk (*B*)
+ (pool.malloc)(); // loses the pointer to the returned chunk (*B*)
// pool's destructor should purge the memory
// This will clean up the memory leak from (*B*)
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk