├── .appveyor.yml ├── .codecov.yml ├── .gitattributes ├── .github └── workflows │ └── ci.yml ├── CMakeLists.txt ├── LICENSE ├── README.md ├── build.jam ├── doc ├── html │ ├── BOOST_POOL_VALIDATE_INTERNALS.html │ ├── boost │ │ ├── default_user_allocator_malloc_free.html │ │ ├── default_user_allocator_new_delete.html │ │ ├── fast_pool_allocator.html │ │ ├── fast_pool_allocator │ │ │ └── rebind.html │ │ ├── fast_pool_allocator_tag.html │ │ ├── fast_pool_allocator_void__UserAllocat_id378528.html │ │ ├── fast_pool_allocator_void__UserAllocat_id378528 │ │ │ └── rebind.html │ │ ├── object_pool.html │ │ ├── pool.html │ │ ├── pool_allocator.html │ │ ├── pool_allocator │ │ │ └── rebind.html │ │ ├── pool_allocator_tag.html │ │ ├── pool_allocator_void__UserAllocator__M_id378014.html │ │ ├── pool_allocator_void__UserAllocator__M_id378014 │ │ │ └── rebind.html │ │ ├── simple_segregated_storage.html │ │ ├── singleton_pool.html │ │ └── singleton_pool │ │ │ └── object_creator.html │ ├── boost_pool │ │ ├── appendices.html │ │ ├── appendices │ │ │ ├── acknowledgements.html │ │ │ ├── faq.html │ │ │ ├── history.html │ │ │ ├── implementations.html │ │ │ ├── references.html │ │ │ ├── tests.html │ │ │ ├── tickets.html │ │ │ └── todo.html │ │ ├── indexes.html │ │ ├── indexes │ │ │ ├── s01.html │ │ │ ├── s02.html │ │ │ ├── s03.html │ │ │ └── s04.html │ │ ├── pool.html │ │ └── pool │ │ │ ├── conventions.html │ │ │ ├── installation.html │ │ │ ├── interfaces.html │ │ │ ├── introduction.html │ │ │ ├── pooling.html │ │ │ ├── testing.html │ │ │ └── usage.html │ ├── boost_pool_c___reference.html │ ├── header │ │ └── boost │ │ │ └── pool │ │ │ ├── object_pool_hpp.html │ │ │ ├── pool_alloc_hpp.html │ │ │ ├── pool_hpp.html │ │ │ ├── poolfwd_hpp.html │ │ │ ├── simple_segregated_storage_hpp.html │ │ │ └── singleton_pool_hpp.html │ └── index.html ├── images │ ├── mb1.png │ ├── mb1.svg │ ├── mb2.png │ ├── mb2.svg │ ├── mb3.png │ ├── mb3.svg │ ├── mb4.png │ ├── mb4.svg │ ├── pc1.png │ ├── pc1.svg │ ├── pc2.png │ ├── pc2.svg │ ├── pc3.png │ ├── pc3.svg │ ├── pc4.png │ ├── pc4.svg │ ├── pc5.png │ └── pc5.svg ├── index.html ├── index.idx ├── jamfile.v2 ├── pool.pdf └── pool.qbk ├── example ├── Jamfile.v2 ├── sys_allocator.hpp └── time_pool_alloc.cpp ├── include └── boost │ └── pool │ ├── detail │ ├── for.m4 │ ├── guard.hpp │ ├── mutex.hpp │ ├── pool_construct.bat │ ├── pool_construct.ipp │ ├── pool_construct.m4 │ ├── pool_construct.sh │ ├── pool_construct_simple.bat │ ├── pool_construct_simple.ipp │ ├── pool_construct_simple.m4 │ └── pool_construct_simple.sh │ ├── object_pool.hpp │ ├── pool.hpp │ ├── pool_alloc.hpp │ ├── poolfwd.hpp │ ├── simple_segregated_storage.hpp │ └── singleton_pool.hpp ├── index.html ├── meta └── libraries.json └── test ├── Jamfile.v2 ├── cmake_test ├── CMakeLists.txt └── main.cpp ├── pool_msvc_compiler_bug_test.cpp ├── random_shuffle.hpp ├── suppressions.txt ├── test_bug_1252.cpp ├── test_bug_2696.cpp ├── test_bug_3349.cpp ├── test_bug_4960.cpp ├── test_bug_5526.cpp ├── test_bug_6701.cpp ├── test_msvc_mem_leak_detect.cpp ├── test_poisoned_macros.cpp ├── test_pool_alloc.cpp ├── test_simple_seg_storage.cpp ├── test_simple_seg_storage.hpp ├── test_threading.cpp ├── test_valgrind_fail_1.cpp ├── test_valgrind_fail_2.cpp ├── track_allocator.hpp └── valgrind_config_check.cpp /.appveyor.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2016, 2017 Peter Dimov 2 | # Copyright 2017 - 2019 James E. King III 3 | # Copyright 2019 - 2021 Alexander Grund 4 | # Distributed under the Boost Software License, Version 1.0. 5 | # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) 6 | 7 | # 8 | # Generic Appveyor build script for boostorg repositories 9 | # See: https://github.com/boostorg/boost-ci/ 10 | # 11 | # Instructions for customizing this script for your library: 12 | # 13 | # 1. Customize the compilers and language levels you want. 14 | # 2. If you have more than include/, src/, test/, example/, examples/, 15 | # benchmark/ or tools/ directories, set the environment variable DEPINST. 16 | # For example if your build uses code in "bench/" and "fog/" directories: 17 | # - DEPINST: --include bench --include fog 18 | # 3. Enable pull request builds in your boostorg/ account. 19 | # 20 | # That's it - the script will do everything else for you. 21 | # 22 | 23 | version: 1.0.{build}-{branch} 24 | 25 | shallow_clone: true 26 | 27 | branches: 28 | only: 29 | - master 30 | - develop 31 | - /bugfix\/.*/ 32 | - /feature\/.*/ 33 | - /fix\/.*/ 34 | - /pr\/.*/ 35 | 36 | skip_commits: 37 | files: 38 | - LICENSE 39 | - meta/* 40 | - README.md 41 | 42 | matrix: 43 | fast_finish: false 44 | # Adding MAYFAIL to any matrix job allows it to fail but the build stays green: 45 | allow_failures: 46 | - MAYFAIL: true 47 | 48 | environment: 49 | global: 50 | B2_CI_VERSION: 1 51 | GIT_FETCH_JOBS: 4 52 | # see: http://www.boost.org/build/doc/html/bbv2/overview/invocation.html#bbv2.overview.invocation.properties 53 | # to use the default for a given environment, comment it out; recommend you build debug and release however: 54 | # on Windows it is important to exercise all the possibilities, especially shared vs static, however most 55 | # libraries that care about this exercise it in their Jamfiles... 56 | B2_ADDRESS_MODEL: 32,64 57 | B2_LINK: shared,static 58 | # B2_THREADING: threading=multi,single 59 | B2_VARIANT: release 60 | 61 | matrix: 62 | - FLAVOR: Visual Studio 2017 C++2a Strict 63 | APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 64 | B2_CXXFLAGS: -permissive- 65 | B2_CXXSTD: 2a 66 | B2_TOOLSET: msvc-14.1 67 | 68 | - FLAVOR: Visual Studio 2017 C++14/17 69 | APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 70 | B2_CXXSTD: 14,17 71 | B2_TOOLSET: msvc-14.1 72 | 73 | - FLAVOR: cygwin (32-bit) 74 | APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 75 | ADDPATH: C:\cygwin\bin; 76 | B2_ADDRESS_MODEL: 32 77 | B2_CXXSTD: 03,11,14,1z 78 | B2_TOOLSET: gcc 79 | 80 | - FLAVOR: cygwin (64-bit) 81 | APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 82 | ADDPATH: C:\cygwin64\bin; 83 | B2_ADDRESS_MODEL: 64 84 | B2_CXXSTD: 03,11,14,1z 85 | B2_TOOLSET: gcc 86 | 87 | install: 88 | - git clone --depth 1 https://github.com/boostorg/boost-ci.git C:\boost-ci-cloned 89 | # Copy ci folder if not testing Boost.CI 90 | - if NOT "%APPVEYOR_PROJECT_NAME%" == "boost-ci" xcopy /s /e /q /i /y C:\boost-ci-cloned\ci .\ci 91 | - rmdir /s /q C:\boost-ci-cloned 92 | - ci\appveyor\install.bat 93 | 94 | build: off 95 | 96 | test_script: ci\build.bat 97 | 98 | -------------------------------------------------------------------------------- /.codecov.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 - 2021 Alexander Grund 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) 4 | # 5 | # Sample codecov configuration file. Edit as required 6 | 7 | codecov: 8 | max_report_age: off 9 | require_ci_to_pass: yes 10 | notify: 11 | # Increase this if you have multiple coverage collection jobs 12 | after_n_builds: 2 13 | wait_for_ci: yes 14 | 15 | parsers: 16 | gcov: 17 | branch_detection: 18 | conditional: yes 19 | loop: yes 20 | method: no 21 | macro: no 22 | 23 | # Change how pull request comments look 24 | comment: 25 | layout: "reach,diff,flags,files,footer" 26 | 27 | # Ignore specific files or folders. Glob patterns are supported. 28 | # See https://docs.codecov.com/docs/ignoring-paths 29 | ignore: 30 | - libs/pool/test/ 31 | - test/ 32 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto !eol svneol=native#text/plain 2 | *.gitattributes text svneol=native#text/plain 3 | 4 | # Scriptish formats 5 | *.bat text svneol=native#text/plain 6 | *.bsh text svneol=native#text/x-beanshell 7 | *.cgi text svneol=native#text/plain 8 | *.cmd text svneol=native#text/plain 9 | *.js text svneol=native#text/javascript 10 | *.php text svneol=native#text/x-php 11 | *.pl text svneol=native#text/x-perl 12 | *.pm text svneol=native#text/x-perl 13 | *.py text svneol=native#text/x-python 14 | *.sh eol=lf svneol=LF#text/x-sh 15 | configure eol=lf svneol=LF#text/x-sh 16 | 17 | # Image formats 18 | *.bmp binary svneol=unset#image/bmp 19 | *.gif binary svneol=unset#image/gif 20 | *.ico binary svneol=unset#image/ico 21 | *.jpeg binary svneol=unset#image/jpeg 22 | *.jpg binary svneol=unset#image/jpeg 23 | *.png binary svneol=unset#image/png 24 | *.tif binary svneol=unset#image/tiff 25 | *.tiff binary svneol=unset#image/tiff 26 | *.svg text svneol=native#image/svg%2Bxml 27 | 28 | # Data formats 29 | *.pdf binary svneol=unset#application/pdf 30 | *.avi binary svneol=unset#video/avi 31 | *.doc binary svneol=unset#application/msword 32 | *.dsp text svneol=crlf#text/plain 33 | *.dsw text svneol=crlf#text/plain 34 | *.eps binary svneol=unset#application/postscript 35 | *.gz binary svneol=unset#application/gzip 36 | *.mov binary svneol=unset#video/quicktime 37 | *.mp3 binary svneol=unset#audio/mpeg 38 | *.ppt binary svneol=unset#application/vnd.ms-powerpoint 39 | *.ps binary svneol=unset#application/postscript 40 | *.psd binary svneol=unset#application/photoshop 41 | *.rdf binary svneol=unset#text/rdf 42 | *.rss text svneol=unset#text/xml 43 | *.rtf binary svneol=unset#text/rtf 44 | *.sln text svneol=native#text/plain 45 | *.swf binary svneol=unset#application/x-shockwave-flash 46 | *.tgz binary svneol=unset#application/gzip 47 | *.vcproj text svneol=native#text/xml 48 | *.vcxproj text svneol=native#text/xml 49 | *.vsprops text svneol=native#text/xml 50 | *.wav binary svneol=unset#audio/wav 51 | *.xls binary svneol=unset#application/vnd.ms-excel 52 | *.zip binary svneol=unset#application/zip 53 | 54 | # Text formats 55 | .htaccess text svneol=native#text/plain 56 | *.bbk text svneol=native#text/xml 57 | *.cmake text svneol=native#text/plain 58 | *.css text svneol=native#text/css 59 | *.dtd text svneol=native#text/xml 60 | *.htm text svneol=native#text/html 61 | *.html text svneol=native#text/html 62 | *.ini text svneol=native#text/plain 63 | *.log text svneol=native#text/plain 64 | *.mak text svneol=native#text/plain 65 | *.qbk text svneol=native#text/plain 66 | *.rst text svneol=native#text/plain 67 | *.sql text svneol=native#text/x-sql 68 | *.txt text svneol=native#text/plain 69 | *.xhtml text svneol=native#text/xhtml%2Bxml 70 | *.xml text svneol=native#text/xml 71 | *.xsd text svneol=native#text/xml 72 | *.xsl text svneol=native#text/xml 73 | *.xslt text svneol=native#text/xml 74 | *.xul text svneol=native#text/xul 75 | *.yml text svneol=native#text/plain 76 | boost-no-inspect text svneol=native#text/plain 77 | CHANGES text svneol=native#text/plain 78 | COPYING text svneol=native#text/plain 79 | INSTALL text svneol=native#text/plain 80 | Jamfile text svneol=native#text/plain 81 | Jamroot text svneol=native#text/plain 82 | Jamfile.v2 text svneol=native#text/plain 83 | Jamrules text svneol=native#text/plain 84 | Makefile* text svneol=native#text/plain 85 | README text svneol=native#text/plain 86 | TODO text svneol=native#text/plain 87 | 88 | # Code formats 89 | *.c text svneol=native#text/plain 90 | *.cpp text svneol=native#text/plain 91 | *.h text svneol=native#text/plain 92 | *.hpp text svneol=native#text/plain 93 | *.ipp text svneol=native#text/plain 94 | *.tpp text svneol=native#text/plain 95 | *.jam text svneol=native#text/plain 96 | *.java text svneol=native#text/plain 97 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Mike Dev 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | cmake_minimum_required(VERSION 3.5...3.20) 6 | project(boost_pool VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) 7 | 8 | add_library(boost_pool INTERFACE) 9 | add_library(Boost::pool ALIAS boost_pool) 10 | 11 | target_include_directories(boost_pool INTERFACE include) 12 | 13 | target_link_libraries(boost_pool 14 | INTERFACE 15 | Boost::assert 16 | Boost::config 17 | Boost::integer 18 | Boost::throw_exception 19 | Boost::type_traits 20 | Boost::winapi 21 | ) 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Pool, part of collection of the [Boost C++ Libraries](https://github.com/boostorg), provides an efficient way to handle memory suballocation for fixed-size items. 2 | 3 | ### License 4 | 5 | Distributed under the [Boost Software License, Version 1.0](https://www.boost.org/LICENSE_1_0.txt). 6 | 7 | ### Properties 8 | 9 | * C++03 10 | * Header Only 11 | 12 | ### Build Status 13 | 14 | 15 | | Branch | GHA CI | Appveyor | Coverity Scan | codecov.io | Deps | Docs | Tests | 16 | | :-------------: | ------ | -------- | ------------- | ---------- | ---- | ---- | ----- | 17 | | [`master`](https://github.com/boostorg/pool/tree/master) | [![Build Status](https://github.com/boostorg/pool/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/boostorg/pool/actions?query=branch:master) | [![Build status](https://ci.appveyor.com/api/projects/status/j6otdvyec8ycs9h1/branch/master?svg=true)](https://ci.appveyor.com/project/cppalliance/pool/branch/master) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/15800/badge.svg)](https://scan.coverity.com/projects/boostorg-pool) | [![codecov](https://codecov.io/gh/boostorg/pool/branch/master/graph/badge.svg?token=blmk8CZxg2)](https://codecov.io/gh/boostorg/pool/tree/master) | [![Deps](https://img.shields.io/badge/deps-master-brightgreen.svg)](https://pdimov.github.io/boostdep-report/master/pool.html) | [![Documentation](https://img.shields.io/badge/docs-master-brightgreen.svg)](https://www.boost.org/doc/libs/master/libs/pool) | [![Enter the Matrix](https://img.shields.io/badge/matrix-master-brightgreen.svg)](https://www.boost.org/development/tests/master/developer/pool.html) 18 | | [`develop`](https://github.com/boostorg/pool/tree/develop) | [![Build Status](https://github.com/boostorg/pool/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/boostorg/pool/actions?query=branch:develop) | [![Build status](https://ci.appveyor.com/api/projects/status/j6otdvyec8ycs9h1/branch/develop?svg=true)](https://ci.appveyor.com/project/cppalliance/pool/branch/develop) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/15800/badge.svg)](https://scan.coverity.com/projects/boostorg-pool) | [![codecov](https://codecov.io/gh/boostorg/pool/branch/develop/graph/badge.svg?token=blmk8CZxg2)](https://codecov.io/gh/boostorg/pool/tree/develop) | [![Deps](https://img.shields.io/badge/deps-develop-brightgreen.svg)](https://pdimov.github.io/boostdep-report/develop/pool.html) | [![Documentation](https://img.shields.io/badge/docs-develop-brightgreen.svg)](https://www.boost.org/doc/libs/develop/libs/pool) | [![Enter the Matrix](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](https://www.boost.org/development/tests/develop/developer/pool.html) 19 | 20 | ### Directories 21 | 22 | | Name | Purpose | 23 | | ----------- | ------------------------------ | 24 | | `doc` | documentation | 25 | | `example` | examples | 26 | | `include` | headers | 27 | | `test` | unit tests | 28 | 29 | ### More information 30 | 31 | * [Ask questions](https://stackoverflow.com/questions/ask?tags=c%2B%2B,boost,boost-pool) 32 | * [Report bugs](https://github.com/boostorg/pool/issues): Be sure to mention Boost version, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well. 33 | * Submit your patches as pull requests against **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](https://www.boost.org/LICENSE_1_0.txt). 34 | * Discussions about the library are held on the [Boost developers mailing list](https://www.boost.org/community/groups.html#main). Be sure to read the [discussion policy](https://www.boost.org/community/policy.html) before posting and add the `[pool]` tag at the beginning of the subject line. 35 | 36 | -------------------------------------------------------------------------------- /build.jam: -------------------------------------------------------------------------------- 1 | # Copyright René Ferdinand Rivera Morell 2023-2024 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # (See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | require-b2 5.2 ; 7 | 8 | constant boost_dependencies : 9 | /boost/assert//boost_assert 10 | /boost/config//boost_config 11 | /boost/integer//boost_integer 12 | /boost/throw_exception//boost_throw_exception 13 | /boost/type_traits//boost_type_traits 14 | /boost/winapi//boost_winapi ; 15 | 16 | project /boost/pool 17 | : common-requirements 18 | include 19 | ; 20 | 21 | explicit 22 | [ alias boost_pool : : : : $(boost_dependencies) ] 23 | [ alias all : boost_pool example test ] 24 | ; 25 | 26 | call-if 27 | : boost-library pool 28 | ; 29 | 30 | -------------------------------------------------------------------------------- /doc/html/BOOST_POOL_VALIDATE_INTERNALS.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Macro BOOST_POOL_VALIDATE_INTERNALS 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 |
26 |
27 |
28 |

Macro BOOST_POOL_VALIDATE_INTERNALS

29 |

BOOST_POOL_VALIDATE_INTERNALS

30 |
31 |

Synopsis

32 |
// In header: <boost/pool/simple_segregated_storage.hpp>
33 | 
34 | BOOST_POOL_VALIDATE_INTERNALS
35 |
36 | 37 | 38 | 43 |
44 |
45 |
46 | PrevUpHomeNext 47 |
48 | 49 | 50 | -------------------------------------------------------------------------------- /doc/html/boost/fast_pool_allocator/rebind.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Struct template rebind 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 |
26 |
27 |
28 |

Struct template rebind

29 |

boost::fast_pool_allocator::rebind — Nested class rebind allows for transformation from fast_pool_allocator<T> to fast_pool_allocator<U>.

30 |
31 |

Synopsis

32 |
// In header: <boost/pool/pool_alloc.hpp>
33 | 
34 | 
35 | 
36 | // Nested class rebind allows for transformation from fast_pool_allocator<T>
37 | // to fast_pool_allocator<U>.
38 | template<typename U> 
39 | struct rebind {
40 |   // types
41 |   typedef fast_pool_allocator< U, UserAllocator, Mutex, NextSize, MaxSize > other;
42 | };
43 |
44 |

Description

45 |

Nested class rebind allows for transformation from fast_pool_allocator<T> to fast_pool_allocator<U> via the member typedef other.

46 |
47 |
48 | 49 | 50 | 55 |
56 |
57 |
58 | PrevUpHomeNext 59 |
60 | 61 | 62 | -------------------------------------------------------------------------------- /doc/html/boost/fast_pool_allocator_tag.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Struct fast_pool_allocator_tag 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 |
26 |
27 |
28 |

Struct fast_pool_allocator_tag

29 |

boost::fast_pool_allocator_tag — Simple tag type used by fast_pool_allocator as a template parameter to the underlying singleton_pool.

30 |
31 |

Synopsis

32 |
// In header: <boost/pool/pool_alloc.hpp>
33 | 
34 | 
35 | struct fast_pool_allocator_tag {
36 | };
37 |
38 | 39 | 40 | 45 |
46 |
47 |
48 | PrevUpHomeNext 49 |
50 | 51 | 52 | -------------------------------------------------------------------------------- /doc/html/boost/fast_pool_allocator_void__UserAllocat_id378528/rebind.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Struct template rebind 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 |
26 |
27 |
28 |

Struct template rebind

29 |

boost::fast_pool_allocator<void, UserAllocator, Mutex, NextSize, MaxSize>::rebind — Nested class rebind allows for transformation from fast_pool_allocator<T> to fast_pool_allocator<U>.

30 |
31 |

Synopsis

32 |
// In header: <boost/pool/pool_alloc.hpp>
33 | 
34 | 
35 | 
36 | // Nested class rebind allows for transformation from fast_pool_allocator<T>
37 | // to fast_pool_allocator<U>.
38 | template<typename U> 
39 | struct rebind {
40 |   // types
41 |   typedef fast_pool_allocator< U, UserAllocator, Mutex, NextSize, MaxSize > other;
42 | };
43 |
44 |

Description

45 |

Nested class rebind allows for transformation from fast_pool_allocator<T> to fast_pool_allocator<U> via the member typedef other.

46 |
47 |
48 | 49 | 50 | 55 |
56 |
57 |
58 | PrevUpHomeNext 59 |
60 | 61 | 62 | -------------------------------------------------------------------------------- /doc/html/boost/pool_allocator/rebind.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Struct template rebind 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 |
26 |
27 |
28 |

Struct template rebind

29 |

boost::pool_allocator::rebind — Nested class rebind allows for transformation from pool_allocator<T> to pool_allocator<U>.

30 |
31 |

Synopsis

32 |
// In header: <boost/pool/pool_alloc.hpp>
33 | 
34 | 
35 | 
36 | // Nested class rebind allows for transformation from pool_allocator<T> to
37 | // pool_allocator<U>.
38 | template<typename U> 
39 | struct rebind {
40 |   // types
41 |   typedef pool_allocator< U, UserAllocator, Mutex, NextSize, MaxSize > other;
42 | };
43 |
44 |

Description

45 |

Nested class rebind allows for transformation from pool_allocator<T> to pool_allocator<U> via the member typedef other.

46 |
47 |
48 | 49 | 50 | 55 |
56 |
57 |
58 | PrevUpHomeNext 59 |
60 | 61 | 62 | -------------------------------------------------------------------------------- /doc/html/boost/pool_allocator_tag.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Struct pool_allocator_tag 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 |
26 |
27 |
28 |

Struct pool_allocator_tag

29 |

boost::pool_allocator_tag

30 |
31 |

Synopsis

32 |
// In header: <boost/pool/pool_alloc.hpp>
33 | 
34 | 
35 | struct pool_allocator_tag {
36 | };
37 |
38 |

Description

39 |

Simple tag type used by pool_allocator as an argument to the underlying singleton_pool.

40 |
41 |
42 | 43 | 44 | 49 |
50 |
51 |
52 | PrevUpHomeNext 53 |
54 | 55 | 56 | -------------------------------------------------------------------------------- /doc/html/boost/pool_allocator_void__UserAllocator__M_id378014/rebind.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Struct template rebind 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 |
26 |
27 |
28 |

Struct template rebind

29 |

boost::pool_allocator<void, UserAllocator, Mutex, NextSize, MaxSize>::rebind — Nested class rebind allows for transformation from pool_allocator<T> to pool_allocator<U>.

30 |
31 |

Synopsis

32 |
// In header: <boost/pool/pool_alloc.hpp>
33 | 
34 | 
35 | 
36 | // Nested class rebind allows for transformation from pool_allocator<T> to
37 | // pool_allocator<U>.
38 | template<typename U> 
39 | struct rebind {
40 |   // types
41 |   typedef pool_allocator< U, UserAllocator, Mutex, NextSize, MaxSize > other;
42 | };
43 |
44 |

Description

45 |

Nested class rebind allows for transformation from pool_allocator<T> to pool_allocator<U> via the member typedef other.

46 |
47 |
48 | 49 | 50 | 55 |
56 |
57 |
58 | PrevUpHomeNext 59 |
60 | 61 | 62 | -------------------------------------------------------------------------------- /doc/html/boost/singleton_pool/object_creator.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Struct object_creator 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 |
26 |
27 |
28 |

Struct object_creator

29 |

boost::singleton_pool::object_creator

30 |
31 |

Synopsis

32 |
// In header: <boost/pool/singleton_pool.hpp>
33 | 
34 | 
35 | 
36 | struct object_creator {
37 |   // construct/copy/destruct
38 |   object_creator();
39 | 
40 |   // public member functions
41 |   void do_nothing() const;
42 | };
43 |
44 |

Description

45 |
46 |

47 | object_creator 48 | public 49 | construct/copy/destruct

50 |
  1. object_creator();
51 |
52 |
53 |

54 | object_creator public member functions

55 |
  1. void do_nothing() const;
56 |
57 |
58 |
59 | 60 | 61 | 66 |
67 |
68 |
69 | PrevUpHomeNext 70 |
71 | 72 | 73 | -------------------------------------------------------------------------------- /doc/html/boost_pool/appendices.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Appendices 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 | 41 | 42 | 43 | 48 |
49 |
50 |
51 | PrevUpHomeNext 52 |
53 | 54 | 55 | -------------------------------------------------------------------------------- /doc/html/boost_pool/appendices/acknowledgements.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Appendix C: Acknowledgements 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 |
26 | 29 |

30 | Many, many thanks to the Boost peers, notably Jeff Garland, Beman Dawes, 31 | Ed Brey, Gary Powell, Peter Dimov, and Jens Maurer for providing helpful 32 | suggestions! 33 |

34 |
35 | 36 | 37 | 42 |
43 |
44 |
45 | PrevUpHomeNext 46 |
47 | 48 | 49 | -------------------------------------------------------------------------------- /doc/html/boost_pool/appendices/faq.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Appendix B: FAQ 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 |
26 |

27 | Appendix B: FAQ 28 |

29 |
30 | 31 | Why 32 | should I use Pool? 33 |
34 |

35 | Using Pools gives you more control over how memory is used in your program. 36 | For example, you could have a situation where you want to allocate a bunch 37 | of small objects at one point, and then reach a point in your program where 38 | none of them are needed any more. Using pool interfaces, you can choose to 39 | run their destructors or just drop them off into oblivion; the pool interface 40 | will guarantee that there are no system memory leaks. 41 |

42 |
43 | 44 | When 45 | should I use Pool? 46 |
47 |

48 | Pools are generally used when there is a lot of allocation and deallocation 49 | of small objects. Another common usage is the situation above, where many 50 | objects may be dropped out of memory. 51 |

52 |

53 | In general, use Pools when you need a more efficient way to do unusual memory 54 | control. 55 |

56 |
57 | 58 | 59 | 64 |
65 |
66 |
67 | PrevUpHomeNext 68 |
69 | 70 | 71 | -------------------------------------------------------------------------------- /doc/html/boost_pool/appendices/history.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Appendix A: History 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 |
26 | 29 |
30 | 31 | Version 32 | 2.0.0, January 11, 2011 33 |
34 |

35 | Documentation and testing revision 36 |

37 |

38 | Features: 39 |

40 |
    41 |
  • 42 | Fix issues 1252, 43 | 4960, 44 | 5526, 45 | 5700, 46 | 2696. 47 |
  • 48 |
  • 49 | Documentation converted and rewritten and revised by Paul A. Bristow 50 | using Quickbook, Doxygen, for html and pdf, based on Stephen Cleary's 51 | html version, Revised 05 December, 2006. 52 |
  • 53 |
54 |

55 | This used Opera 11.0, and html_to_quickbook.css as 56 | a special display format. On the Opera full taskbar (chose enable 57 | full taskbar) View, Style, Manage modes, Display. 58 |

59 |

60 | Choose add \boost-sandbox\boost_docs\trunk\doc\style\html\conversion\html_to_quickbook.css 61 | to My Style Sheet. Html pages are now displayed as Quickbook and can be copied 62 | and pasted into quickbook files using your favored text editor for Quickbook. 63 |

64 |
65 | 66 | Version 67 | 1.0.0, January 1, 2000 68 |
69 |

70 | First release 71 |

72 |
73 | 74 | 75 | 80 |
81 |
82 |
83 | PrevUpHomeNext 84 |
85 | 86 | 87 | -------------------------------------------------------------------------------- /doc/html/boost_pool/appendices/references.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Appendix G: References 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 |
26 | 29 |
    30 |
  1. 31 | Doug Lea, A Memory Allocator. See http://gee.cs.oswego.edu/dl/html/malloc.html 32 |
  2. 33 |
  3. 34 | Paul R. Wilson, Mark S. Johnstone, Michael Neely, 35 | and David Boles, Dynamic Storage Allocation: A Survey and Critical 36 | Review in International Workshop on Memory Management, September 37 | 1995, pg. 28, 36. See ftp://ftp.cs.utexas.edu/pub/garbage/allocsrv.ps 38 |
  4. 39 |
40 |
41 | 42 | 43 | 48 |
49 |
50 |
51 | PrevUpHomeNext 52 |
53 | 54 | 55 | -------------------------------------------------------------------------------- /doc/html/boost_pool/appendices/tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Appendix D: Tests 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 |
26 |

27 | Appendix D: Tests 28 |

29 |

30 | See folder boost/libs/pool/test/. 31 |

32 |
33 | 34 | 35 | 40 |
41 |
42 |
43 | PrevUpHomeNext 44 |
45 | 46 | 47 | -------------------------------------------------------------------------------- /doc/html/boost_pool/appendices/tickets.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Appendix E: Tickets 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 |
26 | 29 |

30 | Report and view bugs and features by adding a ticket at Boost.Trac. 31 |

32 |

33 | Existing open tickets for this library alone can be viewed here. 34 | Existing tickets for this library - including closed ones - can be viewed 35 | here. 36 |

37 |
38 | 39 | 40 | 45 |
46 |
47 |
48 | PrevUpHomeNext 49 |
50 | 51 | 52 | -------------------------------------------------------------------------------- /doc/html/boost_pool/appendices/todo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Appendix H: Future plans 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 |
26 | 29 |

30 | Another pool interface will be written: a base class for per-class pool allocation. 31 |

32 |

33 | This "pool_base" interface will be Singleton Usage with Exceptions, 34 | and built on the singleton_pool interface. 35 |

36 |
37 | 38 | 39 | 44 |
45 |
46 |
47 | PrevUpHomeNext 48 |
49 | 50 | 51 | -------------------------------------------------------------------------------- /doc/html/boost_pool/indexes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Indexes 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 |
26 |

27 | Indexes 28 |

29 |
30 |
Function Index
31 |
Class Index
32 |
Typedef Index
33 |
Index
34 |
35 |
36 | 37 | 38 | 43 |
44 |
45 |
46 | PrevUpHomeNext 47 |
48 | 49 | 50 | -------------------------------------------------------------------------------- /doc/html/boost_pool/pool.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Introduction and Overview 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 | 53 | 54 | 55 | 60 |
61 |
62 |
63 | PrevUpHomeNext 64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /doc/html/boost_pool/pool/conventions.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Documentation Naming and Formatting Conventions 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 |
26 | 30 |

31 | This documentation makes use of the following naming and formatting conventions. 32 |

33 |
    34 |
  • 35 | Code is in fixed width 36 | font and is syntax-highlighted 37 | in color. 38 |
  • 39 |
  • 40 | Replaceable text that you will need to supply is in italics. 41 |
  • 42 |
  • 43 | Free functions are rendered in the code 44 | font followed by (), as in free_function(). 45 |
  • 46 |
  • 47 | If a name refers to a class template, it is specified like this: class_template<>; 48 | that is, it is in code font and its name is followed by <> to indicate that it is a class 49 | template. 50 |
  • 51 |
  • 52 | If a name refers to a function-like macro, it is specified like this: 53 | MACRO(); 54 | that is, it is uppercase in code font and its name is followed by () to indicate that it is a function-like 55 | macro. Object-like macros appear without the trailing (). 56 |
  • 57 |
  • 58 | Names that refer to concepts in the generic programming 59 | sense are specified in CamelCase. 60 |
  • 61 |
62 |
63 | 64 | 65 | 66 | 67 | 71 |
[Note]Note

68 | In addition, notes such as this one specify non-essential information that 69 | provides additional background or rationale. 70 |

72 |

73 | Finally, you can mentally add the following to any code fragments in this 74 | document: 75 |

76 |
// Include all of Pool files
77 | #include <boost/pool.hpp>
78 | 
79 |
80 | 81 | 82 | 87 |
88 |
89 |
90 | PrevUpHomeNext 91 |
92 | 93 | 94 | -------------------------------------------------------------------------------- /doc/html/boost_pool/pool/installation.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Installation 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 |
26 |

27 | Installation 28 |

29 |

30 | The Boost Pool library is a header-only library. That means there is no .lib, 31 | .dll, or .so to build; just add the Boost directory to your compiler's include 32 | file path, and you should be good to go! 33 |

34 |
35 | 36 | 37 | 42 |
43 |
44 |
45 | PrevUpHomeNext 46 |
47 | 48 | 49 | -------------------------------------------------------------------------------- /doc/html/boost_pool/pool/introduction.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Introduction 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 |
26 |

27 | Introduction 28 |

29 |
30 | 31 | What 32 | is Pool? 33 |
34 |

35 | Pool allocation is a memory allocation scheme that is very fast, but limited 36 | in its usage. For more information on pool allocation (also called simple 37 | segregated storage, see concepts 38 | concepts and Simple Segregated 39 | Storage). 40 |

41 |
42 | 43 | Why 44 | should I use Pool? 45 |
46 |

47 | Using Pools gives you more control over how memory is used in your program. 48 | For example, you could have a situation where you want to allocate a bunch 49 | of small objects at one point, and then reach a point in your program where 50 | none of them are needed any more. Using pool interfaces, you can choose to 51 | run their destructors or just drop them off into oblivion; the pool interface 52 | will guarantee that there are no system memory leaks. 53 |

54 |
55 | 56 | When should 57 | I use Pool? 58 |
59 |

60 | Pools are generally used when there is a lot of allocation and deallocation 61 | of small objects. Another common usage is the situation above, where many 62 | objects may be dropped out of memory. 63 |

64 |

65 | In general, use Pools when you need a more efficient way to do unusual memory 66 | control. 67 |

68 |
69 | 70 | Which 71 | pool allocator should I use? 72 |
73 |

74 | pool_allocator is a more 75 | general-purpose solution, geared towards efficiently servicing requests for 76 | any number of contiguous chunks. 77 |

78 |

79 | fast_pool_allocator is also 80 | a general-purpose solution but is geared towards efficiently servicing requests 81 | for one chunk at a time; it will work for contiguous chunks, but not as well 82 | as pool_allocator. 83 |

84 |

85 | If you are seriously concerned about performance, use fast_pool_allocator 86 | when dealing with containers such as std::list, 87 | and use pool_allocator when 88 | dealing with containers such as std::vector. 89 |

90 |
91 | 92 | 93 | 98 |
99 |
100 |
101 | PrevUpHomeNext 102 |
103 | 104 | 105 | -------------------------------------------------------------------------------- /doc/html/boost_pool/pool/testing.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Building the Test Programs 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 |
26 | 29 |

30 | A jamfile.v2 is provided which can be run is the usual way, for example: 31 |

32 |

33 |

34 |
boost\libs\pool\test> bjam -a >pool_test.log
35 |

36 |

37 |
38 | 39 | 40 | 45 |
46 |
47 |
48 | PrevUpHomeNext 49 |
50 | 51 | 52 | -------------------------------------------------------------------------------- /doc/html/boost_pool/pool/usage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | How do I use Pool? 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 |
26 |

27 | How do I use Pool? 28 |

29 |

30 | See the Pool Interfaces 31 | section that covers the different Pool interfaces supplied by this library. 32 |

33 |
34 | 35 | Library 36 | Structure and Dependencies 37 |
38 |

39 | Forward declarations of all the exposed symbols for this library are in the 40 | header made inscope by #include 41 | <boost/pool/poolfwd.hpp>. 42 |

43 |

44 | The library may use macros, which will be prefixed with BOOST_POOL_. 45 | The exception to this rule are the include file guards, which (for file 46 | xxx.hpp) is BOOST_xxx_HPP. 47 |

48 |

49 | All exposed symbols defined by the library will be in namespace boost::. 50 | All symbols used only by the implementation will be in namespace boost::details::pool. 51 |

52 |

53 | Every header used only by the implementation is in the subdirectory /detail/. 54 |

55 |

56 | Any header in the library may include any other header in the library or 57 | any system-supplied header at its discretion. 58 |

59 |
60 | 61 | 62 | 67 |
68 |
69 |
70 | PrevUpHomeNext 71 |
72 | 73 | 74 | -------------------------------------------------------------------------------- /doc/html/boost_pool_c___reference.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Boost.Pool C++ Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 | 42 | 43 | 44 | 49 |
50 |
51 |
52 | PrevUpHomeNext 53 |
54 | 55 | 56 | -------------------------------------------------------------------------------- /doc/html/header/boost/pool/object_pool_hpp.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Header <boost/pool/object_pool.hpp> 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 |
26 | 28 |

Provides a template type boost::object_pool<T, UserAllocator> that can be used for fast and efficient memory allocation of objects of type T. It also provides automatic destruction of non-deallocated objects.

29 |
namespace boost {
30 |   template<typename T, typename UserAllocator> class object_pool;
31 | }
32 |
33 | 34 | 35 | 40 |
41 |
42 |
43 | PrevUpHomeNext 44 |
45 | 46 | 47 | -------------------------------------------------------------------------------- /doc/html/header/boost/pool/pool_hpp.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Header <boost/pool/pool.hpp> 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 |
26 |

27 | Header <boost/pool/pool.hpp>

28 |

Provides class pool: a fast memory allocator that guarantees proper alignment of all allocated chunks, and which extends and generalizes the framework provided by the simple segregated storage solution. Also provides two UserAllocator classes which can be used in conjuction with pool.

29 |
namespace boost {
30 |   struct default_user_allocator_new_delete;
31 |   struct default_user_allocator_malloc_free;
32 | 
33 |   template<typename UserAllocator> class pool;
34 | }
35 |
36 | 37 | 38 | 43 |
44 |
45 |
46 | PrevUpHomeNext 47 |
48 | 49 | 50 | -------------------------------------------------------------------------------- /doc/html/header/boost/pool/poolfwd_hpp.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Header <boost/pool/poolfwd.hpp> 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 |
26 |

27 | Header <boost/pool/poolfwd.hpp>

28 |

Forward declarations of all public (non-implemention) classes.

29 |
30 | 31 | 32 | 37 |
38 |
39 |
40 | PrevUpHomeNext 41 |
42 | 43 | 44 | -------------------------------------------------------------------------------- /doc/html/header/boost/pool/simple_segregated_storage_hpp.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Header <boost/pool/simple_segregated_storage.hpp> 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 |
26 | 28 |

Simple Segregated Storage.

29 |

A simple segregated storage implementation: simple segregated storage is the basic idea behind the Boost Pool library. Simple segregated storage is the simplest, and probably the fastest, memory allocation/deallocation algorithm. It begins by partitioning a memory block into fixed-size chunks. Where the block comes from is not important until implementation time. A Pool is some object that uses Simple Segregated Storage in this fashion.

30 |
31 | 
32 | BOOST_POOL_VALIDATE_INTERNALS
33 |
namespace boost {
34 |   template<typename SizeType> class simple_segregated_storage;
35 | }
36 |
37 | 38 | 39 | 44 |
45 |
46 |
47 | PrevUpHomeNext 48 |
49 | 50 | 51 | -------------------------------------------------------------------------------- /doc/html/header/boost/pool/singleton_pool_hpp.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Header <boost/pool/singleton_pool.hpp> 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 |
26 | 28 |

The singleton_pool class allows other pool interfaces for types of the same size to share the same underlying pool.

29 |

Header singleton_pool.hpp provides a template class singleton_pool, which provides access to a pool as a singleton object.

30 |
namespace boost {
31 |   template<typename Tag, unsigned RequestedSize, typename UserAllocator, 
32 |            typename Mutex, unsigned NextSize, unsigned MaxSize> 
33 |     class singleton_pool;
34 | }
35 |
36 | 37 | 38 | 43 |
44 |
45 |
46 | PrevUpHomeNext 47 |
48 | 49 | 50 | -------------------------------------------------------------------------------- /doc/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Boost.Pool 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
19 |
20 |
Next
21 |
22 |
23 |
24 |

25 | Boost.Pool

26 |

27 | Stephen Cleary 28 |

29 |
30 |
31 |
32 |

33 | Distributed under the Boost Software License, Version 1.0. (See accompanying 34 | file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 35 |

36 |
37 |
38 |
39 |
40 | 85 |
86 | 87 | 88 | 89 |

Last revised: December 15, 2011 at 11:24:47 GMT

90 |
91 |
Next
92 | 93 | 94 | -------------------------------------------------------------------------------- /doc/images/mb1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/pool/740c8076f9d02f0216e8f3dbb15d2fd80f67d7f4/doc/images/mb1.png -------------------------------------------------------------------------------- /doc/images/mb2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/pool/740c8076f9d02f0216e8f3dbb15d2fd80f67d7f4/doc/images/mb2.png -------------------------------------------------------------------------------- /doc/images/mb3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/pool/740c8076f9d02f0216e8f3dbb15d2fd80f67d7f4/doc/images/mb3.png -------------------------------------------------------------------------------- /doc/images/mb4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/pool/740c8076f9d02f0216e8f3dbb15d2fd80f67d7f4/doc/images/mb4.png -------------------------------------------------------------------------------- /doc/images/pc1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/pool/740c8076f9d02f0216e8f3dbb15d2fd80f67d7f4/doc/images/pc1.png -------------------------------------------------------------------------------- /doc/images/pc2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/pool/740c8076f9d02f0216e8f3dbb15d2fd80f67d7f4/doc/images/pc2.png -------------------------------------------------------------------------------- /doc/images/pc3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/pool/740c8076f9d02f0216e8f3dbb15d2fd80f67d7f4/doc/images/pc3.png -------------------------------------------------------------------------------- /doc/images/pc4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/pool/740c8076f9d02f0216e8f3dbb15d2fd80f67d7f4/doc/images/pc4.png -------------------------------------------------------------------------------- /doc/images/pc5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/pool/740c8076f9d02f0216e8f3dbb15d2fd80f67d7f4/doc/images/pc5.png -------------------------------------------------------------------------------- /doc/index.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/pool/740c8076f9d02f0216e8f3dbb15d2fd80f67d7f4/doc/index.html -------------------------------------------------------------------------------- /doc/index.idx: -------------------------------------------------------------------------------- 1 | # index.idx for Boost.Pool Quickbook docs auto-indexing for Boost.Pool 2 | # Copyright (c) 2011 Paul A. Bristow 3 | # 4 | # Use, modification and distribution is subject to the Boost Software 5 | # License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 6 | # http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | # Assume all header files are in boost/pool and sub-folders. 9 | # Perhaps exclude sub-folder /details by setting to false? 10 | !scan-path boost/pool .*\.hpp true 11 | 12 | # Assume all example files are in /example (none in sub-folders). 13 | !scan-path "libs/pool/example" ".*\.cpp" 14 | 15 | align 16 | alignment 17 | alloc 18 | allocation 19 | automatic destruction 20 | block \ 21 | build 22 | chunk \ 23 | concepts \ 24 | conventions 25 | deallocation 26 | dynamic memory allocation 27 | elements 28 | fast pool allocation \ 29 | formatting conventions \ 30 | guaranteeing alignment \ 31 | include \ 32 | installation 33 | headers \ 34 | interface \ 35 | jamfile \ 36 | malloc 37 | memory 38 | memory block 39 | naming 40 | new 41 | objects \ 42 | object_pool 43 | ordered \<\w*(order|unorder)\w*\> 44 | overview 45 | padding \ 46 | portable \ 47 | segregated storage 48 | Simple Segregated Storage 49 | singleton \ 50 | singleton_pool 51 | size \ 52 | template \ 53 | 54 | # \<\w*\> 55 | 56 | !exclude junk 57 | 58 | !rewrite-name "(?i)(?:A|The)\s+(.*)" "\1" 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /doc/jamfile.v2: -------------------------------------------------------------------------------- 1 | # Boost.Pool library documentation Jamfile.v2 2 | # 3 | # Copyright Paul A. Bristow 2011. Use, modification and 4 | # distribution is subject to the Boost Software License, Version 5 | # 1.0. (See accompanying file LICENSE_1_0.txt or copy at 6 | # http://www.boost.org/LICENSE_1_0.txt) 7 | # 8 | # See http://www.boost.org for updates, documentation, and revision history. 9 | 10 | local BOOST = $(BOOST_ROOT) ; 11 | BOOST ?= [ modules.peek : BOOST_ROOT ] ; 12 | BOOST ?= [ modules.peek : BOOST ] ; 13 | path-constant boost-root : $(BOOST) ; 14 | path-constant images_location : images ; # location of SVG and PNG images referenced by Quickbook. 15 | 16 | import modules ; 17 | 18 | using doxygen ; # Required if you want to use Doxygen. 19 | using quickbook ; 20 | 21 | doxygen autodoc 22 | : 23 | [ glob ../include/boost/pool/*.hpp ] 24 | #[ glob ../include/boost/pool/detail/*.hpp ] 25 | #[ glob ../include/boost/pool/detail/*.ipp ] 26 | # Renamed as .inc are not recognised correctly by doxywizard leaving error message. 27 | # Warning: include file boost/pool/detail/pool_construct.inc not found, perhaps you forgot to add its directory to INCLUDE_PATH? 28 | # and problem with 'no type' in jamfile. 29 | # error: target { ../../../boost/pool/detail/pool_construct.inc. } has no type 30 | 31 | #[ glob ../include/boost/pool/examples/*.*pp ] # Example source files. 32 | : 33 | WARNINGS=YES # Default NO, but useful to see warnings, especially in a logfile. 34 | # It is also wise to to set a warnings logfile like this: 35 | WARN_LOGFILE=AutoDoxywarnings.log # This may not be empty (usually not a good sign!), depending on options chosen. 36 | # Much better to send message to a logfile than the default stderr. 37 | # and make sure that there are no Doxygen errors or significant warnings in the log file. 38 | RECURSIVE=NO # Search recursively down subdirectories. 39 | EXTRACT_ALL=NO 40 | HIDE_UNDOC_MEMBERS=YES 41 | EXTRACT_PRIVATE=NO 42 | MACRO_EXPANSION=YES 43 | EXPAND_ONLY_PREDEF=YES 44 | PREDEFINED="\"BOOST_PREVENT_MACRO_SUBSTITUTION=\" \"BOOST_STATIC_CONSTANT(t,v)=static const t v\" \"BOOST_DOXYGEN=1\"" 45 | "boost.doxygen.reftitle=Boost.Pool C++ Reference" 46 | ; 47 | 48 | xml pool : pool.qbk : $(boost-root)/tools/auto_index/include ; 49 | 50 | boostbook standalone 51 | : 52 | pool 53 | : 54 | 55 | # General settings 56 | # ================= 57 | # Options for html and pdf 58 | # ======================== 59 | # No indent on body text: 60 | body.start.indent=0pt 61 | # Margin size: 62 | page.margin.inner=0.5in 63 | # Margin size: 64 | page.margin.outer=0.5in 65 | # Yes, we want graphics for admonishments: 66 | admon.graphics=1 67 | # Path for links to Boost: 68 | boost.root=../../../.. 69 | 70 | # HTML options: 71 | # ============= 72 | # Use graphics icons not text for navigation: 73 | navig.graphics=1 74 | # How far down we chunk nested sections, basically all of them: 75 | chunk.section.depth=2 76 | # Don't put the first section on the same page as the TOC itself: 77 | chunk.first.sections=1 78 | # How far down sections get TOC's 79 | toc.section.depth=4 80 | # Max depth in each TOC: 81 | toc.max.depth=2 82 | # How far down we go with TOC's 83 | generate.section.toc.level=10 84 | # Horizontal ? spacing in table cells. 85 | html:html.cellspacing=3 # pixels 86 | # Vertical spacing in table cells. 87 | html:html.cellpadding=5 # pixels 88 | html:boost.max.id.part.length=40 89 | html:img.src.path=../images/ 90 | 91 | # PDF Options: 92 | # ============ 93 | # TOC Generation: this is needed for FOP-0.9 and later: 94 | pdf:fop1.extensions=0 95 | # Or enable this if you're using XEP: 96 | pdf:xep.extensions=1 97 | # TOC generation: this is needed for FOP 0.2, but must not be set to zero for FOP-0.9! 98 | pdf:fop.extensions=0 99 | # No indent on body text: 100 | body.start.indent=0pt 101 | # Margin size: 102 | page.margin.inner=0.5in 103 | # Margin size: 104 | page.margin.outer=0.5in 105 | 106 | # Yes, we want graphics for admonishments: 107 | admon.graphics=1 108 | 109 | # Set these one for PDF generation *only*: 110 | # default png graphics are awful in PDF form, 111 | # better use SVG instead: 112 | pdf:admon.graphics.extension=".svg" 113 | #pdf:admon.graphics.extension=".png" # Only png images are available. 114 | pdf:use.role.for.mediaobject=1 115 | pdf:preferred.mediaobject.role=print 116 | pdf:img.src.path=$(images_location)/ # graphics (diagrams) for pdf. 117 | pdf:draft.mode="no" 118 | pdf:boost.url.prefix=I:/boost-sandbox/guild/pool/libs/pool/doc/html 119 | 120 | # on turns on index (or off). 121 | on 122 | on 123 | 124 | # Choose indexing method (separately for html and pdf): 125 | html:on # on (or off) to use internally generated indexes. 126 | # html:generate.index=0 # Don't let the XSL stylesheets generate indexes. 127 | 128 | pdf:off # on (or off) to use internally generated indexes. 129 | # index # Use ... as the XML wrapper. 130 | 131 | pdf:index.on.type=1 # For the native stylesheets to generate the different indexes. 132 | # PDF native index support is probably better for PDFs as then you actually get page numbers. 133 | 134 | index.idx # Specifies the name of the script to load. 135 | # ../../../ # Path to /pool so index.idx !scan-path can use boost/ and libs/doc. 136 | ../../.. 137 | 138 | autodoc # 139 | ; 140 | 141 | install pdfinstall : standalone/pdf : . PDF pool.pdf ; 142 | explicit pdfinstall ; 143 | 144 | ############################################################################### 145 | alias boostdoc ; 146 | explicit boostdoc ; 147 | alias boostrelease : standalone ; 148 | explicit boostrelease ; 149 | -------------------------------------------------------------------------------- /doc/pool.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/pool/740c8076f9d02f0216e8f3dbb15d2fd80f67d7f4/doc/pool.pdf -------------------------------------------------------------------------------- /doc/pool.qbk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/pool/740c8076f9d02f0216e8f3dbb15d2fd80f67d7f4/doc/pool.qbk -------------------------------------------------------------------------------- /example/Jamfile.v2: -------------------------------------------------------------------------------- 1 | # Boost.Pool Library example Jamfile 2 | # 3 | # Copyright (c) 2008 James E. King III 4 | # 5 | # Distributed under the Boost Software License, Version 1.0. (See accompany- 6 | # ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | import os ; 9 | import testing ; 10 | 11 | project 12 | : requirements 13 | /boost/pool//boost_pool 14 | /boost/system//boost_system 15 | BOOST_ALL_NO_LIB=1 16 | msvc:_SCL_SECURE_NO_WARNINGS 17 | ; 18 | 19 | if ! [ os.environ VALGRIND_OPTS ] 20 | { 21 | test-suite "pool-examples" 22 | : [ run time_pool_alloc.cpp ] 23 | ; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /example/sys_allocator.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2000 Stephen Cleary 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. (See 4 | // accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #ifndef BOOST_SYS_ALLOCATOR_H 8 | #define BOOST_SYS_ALLOCATOR_H 9 | 10 | #ifdef _MSC_VER 11 | #pragma warning(push) 12 | #pragma warning(disable:4100) 13 | #endif 14 | 15 | // Symbols: malloc_allocator, new_delete_allocator 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | template 23 | struct malloc_allocator 24 | { 25 | typedef T * pointer; 26 | typedef const T * const_pointer; 27 | typedef T & reference; 28 | typedef const T & const_reference; 29 | typedef T value_type; 30 | 31 | typedef std::size_t size_type; 32 | typedef std::ptrdiff_t difference_type; 33 | 34 | template 35 | struct rebind 36 | { 37 | typedef malloc_allocator other; 38 | }; 39 | 40 | static pointer address(reference r) { return &r; } 41 | static const_pointer address(const_reference r) { return &r; } 42 | static pointer allocate(const size_type n, const void* = 0) 43 | { 44 | const pointer ret = (pointer) std::malloc(n * sizeof(T)); 45 | if (ret == 0) 46 | throw std::bad_alloc(); 47 | return ret; 48 | } 49 | static void deallocate(const pointer p, const size_type) 50 | { std::free(p); } 51 | static size_type max_size() { return (std::numeric_limits::max)(); } 52 | 53 | bool operator==(const malloc_allocator &) const { return true; } 54 | bool operator!=(const malloc_allocator &) const { return false; } 55 | 56 | malloc_allocator() { } 57 | template 58 | malloc_allocator(const malloc_allocator &) { } 59 | 60 | static void construct(const pointer p, const_reference t) 61 | { new ((void *) p) T(t); } 62 | static void destroy(const pointer p) 63 | { p->~T(); } 64 | }; 65 | 66 | template 67 | struct new_delete_allocator 68 | { 69 | typedef T * pointer; 70 | typedef const T * const_pointer; 71 | typedef T & reference; 72 | typedef const T & const_reference; 73 | typedef T value_type; 74 | 75 | typedef std::size_t size_type; 76 | typedef std::ptrdiff_t difference_type; 77 | 78 | template 79 | struct rebind 80 | { 81 | typedef new_delete_allocator other; 82 | }; 83 | 84 | static pointer address(reference r) { return &r; } 85 | static const_pointer address(const_reference r) { return &r; } 86 | static pointer allocate(const size_type n, const void* = 0) 87 | { return (pointer) new char[n * sizeof(T)]; } 88 | static void deallocate(const pointer p, const size_type) 89 | { delete [] (char*)p; } 90 | static size_type max_size() { return (std::numeric_limits::max)(); } 91 | 92 | bool operator==(const new_delete_allocator &) const { return true; } 93 | bool operator!=(const new_delete_allocator &) const { return false; } 94 | 95 | new_delete_allocator() { } 96 | template 97 | new_delete_allocator(const new_delete_allocator &) { } 98 | 99 | static void construct(const pointer p, const_reference t) 100 | { new ((void *) p) T(t); } 101 | static void destroy(const pointer p) 102 | { p->~T(); } 103 | }; 104 | 105 | #ifdef _MSC_VER 106 | #pragma warning(pop) 107 | #endif 108 | 109 | #endif 110 | -------------------------------------------------------------------------------- /include/boost/pool/detail/for.m4: -------------------------------------------------------------------------------- 1 | m4_dnl 2 | m4_dnl Copyright (C) 2000 Stephen Cleary 3 | m4_dnl 4 | m4_dnl Distributed under the Boost Software License, Version 1.0. (See accompany- 5 | m4_dnl ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | m4_dnl 7 | m4_dnl See http://www.boost.org for updates, documentation, and revision history. 8 | m4_dnl 9 | m4_dnl 10 | m4_dnl 11 | m4_dnl BOOST_M4_FOR: repeat a given text for a range of values 12 | m4_dnl $1 - variable to hold the current value. 13 | m4_dnl $2 - the starting value. 14 | m4_dnl $3 - the ending value (text is _not_ repeated for this value). 15 | m4_dnl $4 - the text to repeat. 16 | m4_dnl $5 - the delimeter text (optional). 17 | m4_dnl 18 | m4_dnl If the starting value is < ending value: 19 | m4_dnl Will repeat $4, binding $1 to the values in the range [$2, $3). 20 | m4_dnl Else (that is, starting value >= ending value): 21 | m4_dnl Will do nothing 22 | m4_dnl Repeats $5 in-between each occurrence of $4 23 | m4_dnl 24 | m4_dnl Logic: 25 | m4_dnl Set $1 to $2 and call BOOST_M4_FOR_LIST_HELPER: 26 | m4_dnl If $1 >= $3, do nothing 27 | m4_dnl Else 28 | m4_dnl output $4, 29 | m4_dnl set $1 to itself incremented, 30 | m4_dnl If $1 != $3, output $5, 31 | m4_dnl and use recursion 32 | m4_dnl 33 | m4_define(`BOOST_M4_FOR', 34 | `m4_ifelse(m4_eval($# < 4 || $# > 5), 1, 35 | `m4_errprint(m4___file__:m4___line__: `Boost m4 script: BOOST_M4_FOR: Wrong number of arguments ($#)')', 36 | `m4_pushdef(`$1', `$2')BOOST_M4_FOR_HELPER($@)m4_popdef(`$1')')')m4_dnl 37 | m4_define(`BOOST_M4_FOR_HELPER', 38 | `m4_ifelse(m4_eval($1 >= $3), 1, , 39 | `$4`'m4_define(`$1', m4_incr($1))m4_ifelse(m4_eval($1 != $3), 1, `$5')`'BOOST_M4_FOR_HELPER($@)')')m4_dnl 40 | m4_dnl 41 | m4_dnl Testing/Examples: 42 | m4_dnl 43 | m4_dnl The following line will output: 44 | m4_dnl "repeat.m4:42: Boost m4 script: BOOST_M4_FOR: Wrong number of arguments (3)" 45 | m4_dnl BOOST_M4_FOR(i, 1, 3) 46 | m4_dnl 47 | m4_dnl The following line will output: 48 | m4_dnl "repeat.m4:46: Boost m4 script: BOOST_M4_FOR: Wrong number of arguments (6)" 49 | m4_dnl BOOST_M4_FOR(i, 1, 3, i, ` ', 13) 50 | m4_dnl 51 | m4_dnl The following line will output (nothing): 52 | m4_dnl "" 53 | m4_dnl BOOST_M4_FOR(i, 7, 0, i ) 54 | m4_dnl 55 | m4_dnl The following line will output (nothing): 56 | m4_dnl "" 57 | m4_dnl BOOST_M4_FOR(i, 0, 0, i ) 58 | m4_dnl 59 | m4_dnl The following line will output: 60 | m4_dnl "0 1 2 3 4 5 6 " 61 | m4_dnl BOOST_M4_FOR(i, 0, 7, i ) 62 | m4_dnl 63 | m4_dnl The following line will output: 64 | m4_dnl "-13 -12 -11 " 65 | m4_dnl BOOST_M4_FOR(i, -13, -10, i ) 66 | m4_dnl 67 | m4_dnl The following two lines will output: 68 | m4_dnl "(0, 0) (0, 1) (0, 2) (0, 3) " 69 | m4_dnl "(1, 0) (1, 1) (1, 2) (1, 3) " 70 | m4_dnl "(2, 0) (2, 1) (2, 2) (2, 3) " 71 | m4_dnl "(3, 0) (3, 1) (3, 2) (3, 3) " 72 | m4_dnl "(4, 0) (4, 1) (4, 2) (4, 3) " 73 | m4_dnl "(5, 0) (5, 1) (5, 2) (5, 3) " 74 | m4_dnl "(6, 0) (6, 1) (6, 2) (6, 3) " 75 | m4_dnl "(7, 0) (7, 1) (7, 2) (7, 3) " 76 | m4_dnl "" 77 | m4_dnl BOOST_M4_FOR(i, 0, 8, BOOST_M4_FOR(j, 0, 4, (i, j) ) 78 | m4_dnl ) 79 | m4_dnl 80 | m4_dnl The following line will output (nothing): 81 | m4_dnl "" 82 | m4_dnl BOOST_M4_FOR(i, 7, 0, i, |) 83 | m4_dnl 84 | m4_dnl The following line will output (nothing): 85 | m4_dnl "" 86 | m4_dnl BOOST_M4_FOR(i, 0, 0, i, |) 87 | m4_dnl 88 | m4_dnl The following line will output: 89 | m4_dnl "0|1|2|3|4|5|6" 90 | m4_dnl BOOST_M4_FOR(i, 0, 7, i, |) 91 | m4_dnl 92 | m4_dnl The following line will output: 93 | m4_dnl "-13, -12, -11" 94 | m4_dnl BOOST_M4_FOR(i, -13, -10, i, `, ') 95 | m4_dnl 96 | m4_dnl The following two lines will output: 97 | m4_dnl "[(0, 0), (0, 1), (0, 2), (0, 3)]," 98 | m4_dnl "[(1, 0), (1, 1), (1, 2), (1, 3)]," 99 | m4_dnl "[(2, 0), (2, 1), (2, 2), (2, 3)]," 100 | m4_dnl "[(3, 0), (3, 1), (3, 2), (3, 3)]," 101 | m4_dnl "[(4, 0), (4, 1), (4, 2), (4, 3)]," 102 | m4_dnl "[(5, 0), (5, 1), (5, 2), (5, 3)]," 103 | m4_dnl "[(6, 0), (6, 1), (6, 2), (6, 3)]," 104 | m4_dnl "[(7, 0), (7, 1), (7, 2), (7, 3)]" 105 | m4_dnl BOOST_M4_FOR(i, 0, 8, `[BOOST_M4_FOR(j, 0, 4, (i, j), `, ')]', `, 106 | m4_dnl ') 107 | m4_dnl -------------------------------------------------------------------------------- /include/boost/pool/detail/guard.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2000 Stephen Cleary 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. (See 4 | // accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org for updates, documentation, and revision history. 8 | 9 | #ifndef BOOST_POOL_GUARD_HPP 10 | #define BOOST_POOL_GUARD_HPP 11 | 12 | /*! 13 | \file 14 | \brief Extremely Light-Weight guard class. 15 | \details Auto-lock/unlock-er 16 | detail/guard.hpp provides a type guard 17 | that allows scoped access to the Mutex's locking and unlocking operations. 18 | It is used to ensure that a Mutex is unlocked, even if an exception is thrown. 19 | */ 20 | 21 | namespace boost { 22 | 23 | namespace details { 24 | namespace pool { 25 | 26 | template //!< \tparam Mutex (platform-specific) mutex class. 27 | class guard 28 | { //! Locks the mutex, binding guard to Mutex. 29 | /*! Example: 30 | Given a (platform-specific) mutex class, we can wrap code as follows: 31 | 32 | extern mutex global_lock; 33 | 34 | static void f() 35 | { 36 | boost::details::pool::guard g(global_lock); 37 | // g's constructor locks "global_lock" 38 | 39 | ... // do anything: 40 | // throw exceptions 41 | // return 42 | // or just fall through 43 | } // g's destructor unlocks "global_lock" 44 | */ 45 | private: 46 | Mutex & mtx; 47 | 48 | guard(const guard &); //!< Guards the mutex, ensuring unlocked on destruction, even if exception is thrown. 49 | void operator=(const guard &); 50 | 51 | public: 52 | explicit guard(Mutex & nmtx) 53 | :mtx(nmtx) 54 | { //! Locks the mutex of the guard class. 55 | mtx.lock(); 56 | } 57 | 58 | ~guard() 59 | { //! destructor unlocks the mutex of the guard class. 60 | mtx.unlock(); 61 | } 62 | }; // class guard 63 | 64 | } // namespace pool 65 | } // namespace details 66 | 67 | } // namespace boost 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /include/boost/pool/detail/mutex.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2000 Stephen Cleary 2 | // Copyright (C) 2018 Peter Dimov 3 | // 4 | // Distributed under the Boost Software License, Version 1.0. (See 5 | // accompanying file LICENSE_1_0.txt or copy at 6 | // http://www.boost.org/LICENSE_1_0.txt) 7 | // 8 | // See http://www.boost.org for updates, documentation, and revision history. 9 | 10 | #ifndef BOOST_POOL_MUTEX_HPP 11 | #define BOOST_POOL_MUTEX_HPP 12 | 13 | #include 14 | 15 | namespace boost{ namespace details{ namespace pool{ 16 | 17 | class null_mutex 18 | { 19 | private: 20 | 21 | null_mutex(const null_mutex &); 22 | void operator=(const null_mutex &); 23 | 24 | public: 25 | 26 | null_mutex() {} 27 | 28 | static void lock() {} 29 | static void unlock() {} 30 | }; 31 | 32 | }}} // namespace boost::details::pool 33 | 34 | #if !defined(BOOST_HAS_THREADS) || defined(BOOST_NO_MT) || defined(BOOST_POOL_NO_MT) 35 | 36 | namespace boost{ namespace details{ namespace pool{ 37 | 38 | typedef null_mutex default_mutex; 39 | 40 | }}} // namespace boost::details::pool 41 | 42 | #elif !defined(BOOST_NO_CXX11_HDR_MUTEX) 43 | 44 | #include 45 | 46 | namespace boost{ namespace details{ namespace pool{ 47 | 48 | typedef std::mutex default_mutex; 49 | 50 | }}} // namespace boost::details::pool 51 | 52 | #elif defined(BOOST_HAS_PTHREADS) 53 | 54 | #include 55 | #include 56 | 57 | namespace boost{ namespace details{ namespace pool{ 58 | 59 | class pt_mutex 60 | { 61 | private: 62 | 63 | pthread_mutex_t m_; 64 | 65 | pt_mutex(pt_mutex const &); 66 | pt_mutex & operator=(pt_mutex const &); 67 | 68 | public: 69 | 70 | pt_mutex() 71 | { 72 | BOOST_VERIFY( pthread_mutex_init( &m_, 0 ) == 0 ); 73 | } 74 | 75 | ~pt_mutex() 76 | { 77 | BOOST_VERIFY( pthread_mutex_destroy( &m_ ) == 0 ); 78 | } 79 | 80 | void lock() 81 | { 82 | BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); 83 | } 84 | 85 | void unlock() 86 | { 87 | BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); 88 | } 89 | }; 90 | 91 | typedef pt_mutex default_mutex; 92 | 93 | }}} // namespace boost::details::pool 94 | 95 | #elif defined(BOOST_HAS_WINTHREADS) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) 96 | 97 | #include 98 | 99 | namespace boost{ namespace details{ namespace pool{ 100 | 101 | class cs_mutex 102 | { 103 | private: 104 | 105 | boost::winapi::CRITICAL_SECTION_ cs_; 106 | 107 | cs_mutex(cs_mutex const &); 108 | cs_mutex & operator=(cs_mutex const &); 109 | 110 | public: 111 | 112 | cs_mutex() 113 | { 114 | boost::winapi::InitializeCriticalSection( &cs_ ); 115 | } 116 | 117 | ~cs_mutex() 118 | { 119 | boost::winapi::DeleteCriticalSection( &cs_ ); 120 | } 121 | 122 | void lock() 123 | { 124 | boost::winapi::EnterCriticalSection( &cs_ ); 125 | } 126 | 127 | void unlock() 128 | { 129 | boost::winapi::LeaveCriticalSection( &cs_ ); 130 | } 131 | }; 132 | 133 | typedef cs_mutex default_mutex; 134 | 135 | }}} // namespace boost::details::pool 136 | 137 | #else 138 | 139 | // Use #define BOOST_DISABLE_THREADS to avoid this error 140 | # error Unrecognized threading platform 141 | 142 | #endif 143 | 144 | #endif // #ifndef BOOST_POOL_MUTEX_HPP 145 | -------------------------------------------------------------------------------- /include/boost/pool/detail/pool_construct.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem 3 | rem Copyright (C) 2000, 2001 Stephen Cleary 4 | rem 5 | rem Distributed under the Boost Software License, Version 1.0. (See accompany- 6 | rem ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | 9 | 10 | rem Check for Windows NT 11 | if %OS%==Windows_NT goto NT 12 | 13 | rem Not NT - run m4 as normal, then exit 14 | m4 -P -E -DNumberOfArguments=%1 pool_construct.m4 > pool_construct.ipp 15 | goto end 16 | 17 | rem DJGPP programs (including m4) running on Windows/NT do NOT support long 18 | rem file names (see the DJGPP v2 FAQ, question 8.1) 19 | rem Note that the output doesn't have to be a short name because it's an 20 | rem argument to the command shell, not m4. 21 | :NT 22 | m4 -P -E -DNumberOfArguments=%1 < pool_construct.m4 > pool_construct.ipp 23 | 24 | :end 25 | -------------------------------------------------------------------------------- /include/boost/pool/detail/pool_construct.m4: -------------------------------------------------------------------------------- 1 | m4_dnl 2 | m4_dnl Copyright (C) 2000 Stephen Cleary 3 | m4_dnl 4 | m4_dnl Distributed under the Boost Software License, Version 1.0. (See accompany- 5 | m4_dnl ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | m4_dnl 7 | m4_dnl See http://www.boost.org for updates, documentation, and revision history. 8 | m4_dnl 9 | m4_dnl 10 | m4_dnl 11 | m4_dnl Avoid the use of any m4_* identifiers in this header file, 12 | m4_dnl as that may cause incompatibility problems with future 13 | m4_dnl versions of m4. 14 | m4_dnl 15 | m4_dnl This is a normal header file, except that lines starting 16 | m4_dnl with `m4_dnl' will be stripped, TBA_FOR 17 | m4_dnl macros will be replaced with repeated text, and text in 18 | m4_dnl single quotes (`...') will have their single quotes 19 | m4_dnl stripped. 20 | m4_dnl 21 | m4_dnl 22 | m4_dnl Check to make sure NumberOfArguments was defined. If it's not defined, 23 | m4_dnl default to 3 24 | m4_dnl 25 | m4_ifdef(`NumberOfArguments', , `m4_errprint(m4___file__:m4___line__`: NumberOfArguments is not defined; defaulting to 3 26 | ')m4_define(`NumberOfArguments', 3)')m4_dnl 27 | m4_ifelse(NumberOfArguments, , `m4_errprint(m4___file__:m4___line__`: NumberOfArguments is defined to be empty; defaulting to 3 28 | ')m4_define(`NumberOfArguments', 3)')m4_dnl 29 | m4_dnl 30 | m4_dnl Check to make sure NumberOfArguments >= 1. If it's not, then fatal error. 31 | m4_dnl 32 | m4_ifelse(m4_eval(NumberOfArguments < 1), 1, `m4_errprint(m4___file__:m4___line__`: NumberOfArguments ('NumberOfArguments`) is less than 1 33 | ')m4_m4exit(1)')m4_dnl 34 | m4_dnl 35 | m4_dnl Include the BOOST_M4_FOR macro definition 36 | m4_dnl 37 | m4_include(`for.m4')`'m4_dnl 38 | m4_dnl 39 | m4_dnl Begin the generated file. 40 | m4_dnl 41 | // Copyright (C) 2000 Stephen Cleary 42 | // 43 | // Distributed under the Boost Software License, Version 1.0. (See accompany- 44 | // ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 45 | // 46 | // See http://www.boost.org for updates, documentation, and revision history. 47 | 48 | m4_dnl These warnings apply to the file generated from this file. 49 | m4_dnl Of course, you may freely edit this file. 50 | // This file was AUTOMATICALLY GENERATED from "m4___file__" 51 | // Do NOT include directly! 52 | // Do NOT edit! 53 | 54 | m4_dnl 55 | m4_dnl First we define a simple 'cv_qual' macro which takes a number, either 56 | m4_dnl 0, 1, 2, or 3, and determines cv-qualification. 57 | m4_dnl 58 | m4_define(`cv_qual', 59 | `m4_ifelse($1, 0, `', 60 | `m4_ifelse($1, 1, `const ', 61 | `m4_ifelse($1, 2, `volatile ', 62 | `m4_ifelse($1, 3, `const volatile ', 63 | `m4_errprint(m4___file__:m4___line__: `Boost m4 script: cv-determiner: Not 0, 1, 2, or 3 (was '$1`)')' 64 | )')')')')m4_dnl 65 | m4_dnl 66 | m4_dnl Next we go through the actual loop. For each number of arguments from 67 | m4_dnl 1 to NumberOfArguments, we create a template function that takes that 68 | m4_dnl many template arguments, and also generate all cv-qualified permutations 69 | m4_dnl of that function. 70 | m4_dnl 71 | BOOST_M4_FOR(N, 1, NumberOfArguments + 1, 72 | `BOOST_M4_FOR(cv, 0, m4_eval(4 ** N), 73 | `template 74 | element_type * construct(BOOST_M4_FOR(i, 0, N, 75 | `cv_qual(m4_eval((cv >> (i * 2)) % 4))T`'i & a`'i', `, ')) 76 | { 77 | element_type * const ret = (malloc)(); 78 | if (ret == 0) 79 | return ret; 80 | try { new (ret) element_type(BOOST_M4_FOR(i, 0, N, `a`'i', `, ')); } 81 | catch (...) { (free)(ret); throw; } 82 | return ret; 83 | } 84 | ')') 85 | -------------------------------------------------------------------------------- /include/boost/pool/detail/pool_construct.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright (C) 2000 Stephen Cleary 4 | # 5 | # Distributed under the Boost Software License, Version 1.0. (See accompany- 6 | # ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | # 8 | # See http://www.boost.org for updates, documentation, and revision history. 9 | # 10 | 11 | m4 -P -E -DNumberOfArguments=$1 pool_construct.m4 > pool_construct.ipp 12 | 13 | -------------------------------------------------------------------------------- /include/boost/pool/detail/pool_construct_simple.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem 3 | rem Copyright (C) 2001 Stephen Cleary 4 | rem 5 | rem Distributed under the Boost Software License, Version 1.0. (See accompany- 6 | rem ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | rem 8 | rem See http://www.boost.org for updates, documentation, and revision history. 9 | rem 10 | 11 | rem Check for Windows NT 12 | if %OS%==Windows_NT goto NT 13 | 14 | rem Not NT - run m4 as normal, then exit 15 | m4 -P -E -DNumberOfArguments=%1 pool_construct_simple.m4 > pool_construct_simple.ipp 16 | goto end 17 | 18 | rem DJGPP programs (including m4) running on Windows/NT do NOT support long 19 | rem file names (see the DJGPP v2 FAQ, question 8.1) 20 | rem Note that the output doesn't have to be a short name because it's an 21 | rem argument to the command shell, not m4. 22 | :NT 23 | m4 -P -E -DNumberOfArguments=%1 < pool_construct_simple.m4 > pool_construct_simple.ipp 24 | 25 | :end 26 | -------------------------------------------------------------------------------- /include/boost/pool/detail/pool_construct_simple.ipp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2000 Stephen Cleary 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. (See 4 | // accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org for updates, documentation, and revision history. 8 | 9 | // This file was AUTOMATICALLY GENERATED from "stdin" 10 | // Do NOT include directly! 11 | // Do NOT edit! 12 | 13 | template 14 | element_type * construct(const T0 & a0) 15 | { 16 | element_type * const ret = (malloc)(); 17 | if (ret == 0) 18 | return ret; 19 | try { new (ret) element_type(a0); } 20 | catch (...) { (free)(ret); throw; } 21 | return ret; 22 | } 23 | template 24 | element_type * construct(const T0 & a0, const T1 & a1) 25 | { 26 | element_type * const ret = (malloc)(); 27 | if (ret == 0) 28 | return ret; 29 | try { new (ret) element_type(a0, a1); } 30 | catch (...) { (free)(ret); throw; } 31 | return ret; 32 | } 33 | template 34 | element_type * construct(const T0 & a0, const T1 & a1, const T2 & a2) 35 | { 36 | element_type * const ret = (malloc)(); 37 | if (ret == 0) 38 | return ret; 39 | try { new (ret) element_type(a0, a1, a2); } 40 | catch (...) { (free)(ret); throw; } 41 | return ret; 42 | } 43 | 44 | -------------------------------------------------------------------------------- /include/boost/pool/detail/pool_construct_simple.m4: -------------------------------------------------------------------------------- 1 | m4_dnl 2 | m4_dnl Copyright (C) 2001 Stephen Cleary 3 | m4_dnl 4 | m4_dnl Distributed under the Boost Software License, Version 1.0. (See accompany- 5 | m4_dnl ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | m4_dnl 7 | m4_dnl See http://www.boost.org for updates, documentation, and revision history. 8 | m4_dnl 9 | m4_dnl 10 | m4_dnl 11 | m4_dnl Avoid the use of any m4_* identifiers in this header file, 12 | m4_dnl as that may cause incompatibility problems with future 13 | m4_dnl versions of m4. 14 | m4_dnl 15 | m4_dnl This is a normal header file, except that lines starting 16 | m4_dnl with `m4_dnl' will be stripped, TBA_FOR 17 | m4_dnl macros will be replaced with repeated text, and text in 18 | m4_dnl single quotes (`...') will have their single quotes 19 | m4_dnl stripped. 20 | m4_dnl 21 | m4_dnl 22 | m4_dnl Check to make sure NumberOfArguments was defined. If it's not defined, 23 | m4_dnl default to 3 24 | m4_dnl 25 | m4_ifdef(`NumberOfArguments', , `m4_errprint(m4___file__:m4___line__`: NumberOfArguments is not defined; defaulting to 3 26 | ')m4_define(`NumberOfArguments', 3)')m4_dnl 27 | m4_ifelse(NumberOfArguments, , `m4_errprint(m4___file__:m4___line__`: NumberOfArguments is defined to be empty; defaulting to 3 28 | ')m4_define(`NumberOfArguments', 3)')m4_dnl 29 | m4_dnl 30 | m4_dnl Check to make sure NumberOfArguments >= 1. If it's not, then fatal error. 31 | m4_dnl 32 | m4_ifelse(m4_eval(NumberOfArguments < 1), 1, `m4_errprint(m4___file__:m4___line__`: NumberOfArguments ('NumberOfArguments`) is less than 1 33 | ')m4_m4exit(1)')m4_dnl 34 | m4_dnl 35 | m4_dnl Include the BOOST_M4_FOR macro definition 36 | m4_dnl 37 | m4_include(`for.m4')`'m4_dnl 38 | m4_dnl 39 | m4_dnl Begin the generated file. 40 | m4_dnl 41 | // Copyright (C) 2000 Stephen Cleary 42 | // 43 | // Distributed under the Boost Software License, Version 1.0. (See 44 | // accompanying file LICENSE_1_0.txt or copy at 45 | // http://www.boost.org/LICENSE_1_0.txt) 46 | // 47 | // See http://www.boost.org for updates, documentation, and revision history. 48 | 49 | m4_dnl These warnings apply to the file generated from this file. 50 | m4_dnl Of course, you may freely edit this file. 51 | // This file was AUTOMATICALLY GENERATED from "m4___file__" 52 | // Do NOT include directly! 53 | // Do NOT edit! 54 | 55 | m4_dnl 56 | m4_dnl Here we go through the actual loop. For each number of arguments from 57 | m4_dnl 1 to NumberOfArguments, we create a template function that takes that 58 | m4_dnl many template arguments. 59 | m4_dnl 60 | BOOST_M4_FOR(N, 1, NumberOfArguments + 1, 61 | `template 62 | element_type * construct(BOOST_M4_FOR(i, 0, N, 63 | `const T`'i & a`'i', `, ')) 64 | { 65 | element_type * const ret = (malloc)(); 66 | if (ret == 0) 67 | return ret; 68 | try { new (ret) element_type(BOOST_M4_FOR(i, 0, N, `a`'i', `, ')); } 69 | catch (...) { (free)(ret); throw; } 70 | return ret; 71 | } 72 | ') 73 | -------------------------------------------------------------------------------- /include/boost/pool/detail/pool_construct_simple.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright (C) 2001 Stephen Cleary 4 | # 5 | # Distributed under the Boost Software License, Version 1.0. (See accompany- 6 | # ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | # 8 | # See http://www.boost.org for updates, documentation, and revision history. 9 | # 10 | 11 | m4 -P -E -DNumberOfArguments=$1 pool_construct_simple.m4 > pool_construct_simple.ipp 12 | 13 | -------------------------------------------------------------------------------- /include/boost/pool/poolfwd.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2000, 2001 Stephen Cleary 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. (See 4 | // accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org for updates, documentation, and revision history. 8 | 9 | #ifndef BOOST_POOLFWD_HPP 10 | #define BOOST_POOLFWD_HPP 11 | 12 | /*! 13 | \file 14 | \brief Forward declarations of all public (non-implemention) classes. 15 | */ 16 | 17 | 18 | #include // for workarounds 19 | 20 | // std::size_t 21 | #include 22 | 23 | // boost::details::pool::default_mutex 24 | #include 25 | 26 | namespace boost { 27 | 28 | // 29 | // Location: 30 | // 31 | template 32 | class simple_segregated_storage; 33 | 34 | // 35 | // Location: 36 | // 37 | struct default_user_allocator_new_delete; 38 | struct default_user_allocator_malloc_free; 39 | 40 | template 41 | class pool; 42 | 43 | // 44 | // Location: 45 | // 46 | template 47 | class object_pool; 48 | 49 | // 50 | // Location: 51 | // 52 | template 57 | class singleton_pool; 58 | 59 | // 60 | // Location: 61 | // 62 | struct pool_allocator_tag; 63 | 64 | template 69 | class pool_allocator; 70 | 71 | struct fast_pool_allocator_tag; 72 | 73 | template 78 | class fast_pool_allocator; 79 | 80 | } // namespace boost 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/pool/740c8076f9d02f0216e8f3dbb15d2fd80f67d7f4/index.html -------------------------------------------------------------------------------- /meta/libraries.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": "pool", 3 | "name": "Pool", 4 | "authors": [ 5 | "Steve Cleary" 6 | ], 7 | "description": "Memory pool management.", 8 | "category": [ 9 | "Memory" 10 | ], 11 | "maintainers": [ 12 | "Stephen Cleary " 13 | ], 14 | "cxxstd": "03" 15 | } 16 | -------------------------------------------------------------------------------- /test/Jamfile.v2: -------------------------------------------------------------------------------- 1 | #~ Copyright Rene Rivera 2008 2 | #~ Copyright James E. King III 2018 3 | #~ Distributed under the Boost Software License, Version 1.0. 4 | #~ (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | 7 | project 8 | : requirements 9 | /boost/pool//boost_pool 10 | /boost/system//boost_system 11 | BOOST_ALL_NO_LIB=1 12 | all 13 | clang:-Wextra 14 | clang:-Wno-variadic-macros 15 | gcc:-Wextra 16 | gcc:-Wshadow 17 | gcc:-Wno-variadic-macros 18 | msvc:_SCL_SECURE_NO_WARNINGS 19 | ; 20 | 21 | import common ; 22 | import config : requires ; 23 | import os ; 24 | import testing ; 25 | 26 | test-suite pool : 27 | [ run test_simple_seg_storage.cpp : : : /boost/random//boost_random msvc:-wd4267 ] 28 | [ run test_pool_alloc.cpp ] 29 | [ run pool_msvc_compiler_bug_test.cpp : : : /boost/serialization//boost_serialization msvc:-wd4512 ] 30 | [ run test_msvc_mem_leak_detect.cpp ] 31 | [ run test_bug_3349.cpp ] 32 | [ run test_bug_4960.cpp ] 33 | [ run test_bug_1252.cpp : : : 34 | clang:-Wno-c++11-long-long 35 | gcc:-Wno-long-long 36 | pathscale:-Wno-long-long ] 37 | [ run test_bug_2696.cpp ] 38 | [ run test_bug_5526.cpp : : : /boost/smart_ptr//boost_smart_ptr [ requires cxx11_noexcept ] ] 39 | [ run test_bug_6701.cpp ] 40 | [ run test_threading.cpp : : : multi /boost/thread//boost_thread /boost/random//boost_random ] 41 | [ compile test_poisoned_macros.cpp ] 42 | ; 43 | 44 | if [ os.environ VALGRIND_OPTS ] 45 | { 46 | test-suite pool-valgrind : 47 | [ run test_pool_alloc.cpp : : : BOOST_POOL_VALGRIND=1 : test_pool_alloc_valgrind ] 48 | [ run-fail test_valgrind_fail_1.cpp : : : BOOST_POOL_VALGRIND=1 ] 49 | [ run-fail test_valgrind_fail_2.cpp : : : BOOST_POOL_VALGRIND=1 ] 50 | ; 51 | } 52 | 53 | -------------------------------------------------------------------------------- /test/cmake_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2021-2024 Alexander Grund 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | cmake_minimum_required(VERSION 3.5...3.16) 6 | 7 | project(cmake_subdir_test LANGUAGES CXX) 8 | 9 | # Those 2 should work the same 10 | # while using find_package for the installed Boost avoids the need to manually specify dependencies 11 | if(BOOST_CI_INSTALL_TEST) 12 | find_package(boost_pool REQUIRED) 13 | else() 14 | set(BOOST_INCLUDE_LIBRARIES pool) 15 | add_subdirectory(../../../.. deps/boost EXCLUDE_FROM_ALL) 16 | endif() 17 | 18 | add_executable(main main.cpp) 19 | target_link_libraries(main Boost::pool) 20 | 21 | enable_testing() 22 | add_test(NAME main COMMAND main) 23 | -------------------------------------------------------------------------------- /test/cmake_test/main.cpp: -------------------------------------------------------------------------------- 1 | // this is the example from "Pool Interfaces" in the docs 2 | 3 | #include 4 | 5 | int main() 6 | { 7 | boost::pool<> p(sizeof(int)); 8 | for (int i = 0; i < 10000; ++i) 9 | { 10 | void * const t = p.malloc(); 11 | // do something with it 12 | (t); 13 | } 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /test/pool_msvc_compiler_bug_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008 Jurko Gospodnetic 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. (See 4 | // accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | 8 | // This tests whether the Boost Pool library managed to get a regression and 9 | // hit the MSVC 'variables exported to global namespace' bug again. This bug 10 | // affects at least MSVC 7.1 & 8.0 releases and has been fixed in the MSVC 9.0 11 | // release. 12 | // 13 | // If the bug exists this test should fail to compile, complaining about an 14 | // ambiguous CRITICAL_SECTION symbol. The bug got fixed by making the boost/ 15 | // /pool/detail/mutex.hpp header reference all Windows API constants using their 16 | // fully qualified names. 17 | // 18 | // To see the bug in action without using any Boost libraries run the 19 | // following program: 20 | // 21 | // namespace One { class Brick; } 22 | // namespace Two 23 | // { 24 | // using namespace One; 25 | // template class TinyClass {}; 26 | // } 27 | // class Brick {}; 28 | // Brick brick; 29 | // int main() {} 30 | // (17.04.2008.) (Jurko) 31 | 32 | 33 | #include "boost/archive/text_iarchive.hpp" 34 | #include "boost/pool/detail/mutex.hpp" 35 | // Including "boost/pool/pool_alloc.hpp" instead of mutex.hpp should work as 36 | // well. 37 | 38 | int main() 39 | { 40 | } 41 | -------------------------------------------------------------------------------- /test/random_shuffle.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016 Edward Diener 2 | * 3 | * Use, modification and distribution is subject to the 4 | * Boost Software License, Version 1.0. (See accompanying 5 | * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | #ifndef BOOST_POOL_TEST_RANDOM_SHUFFLE_HPP 9 | #define BOOST_POOL_TEST_RANDOM_SHUFFLE_HPP 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | template< class RandomIt > 16 | void pool_test_random_shuffle( RandomIt first, RandomIt last ) 17 | { 18 | typename std::iterator_traits::difference_type i, n; 19 | n = last - first; 20 | for (i = n-1; i > 0; --i) { 21 | using std::swap; 22 | swap(first[i], first[std::rand() % (i+1)]); 23 | } 24 | } 25 | 26 | #endif // BOOST_POOL_TEST_RANDOM_SHUFFLE_HPP 27 | -------------------------------------------------------------------------------- /test/suppressions.txt: -------------------------------------------------------------------------------- 1 | { 2 | no_fishy_value 3 | Memcheck:FishyValue 4 | __builtin_vec_new(size) 5 | fun:_ZnamRKSt9nothrow_t 6 | ... 7 | } 8 | -------------------------------------------------------------------------------- /test/test_bug_1252.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 John Maddock 2 | * 3 | * Use, modification and distribution is subject to the 4 | * Boost Software License, Version 1.0. (See accompanying 5 | * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Test of bug #1252 (https://svn.boost.org/trac/boost/ticket/1252) 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | struct limited_allocator_new_delete 16 | { 17 | typedef std::size_t size_type; 18 | typedef std::ptrdiff_t difference_type; 19 | 20 | static char * malloc BOOST_PREVENT_MACRO_SUBSTITUTION(const size_type bytes) 21 | { 22 | if(bytes > 1510 * 32) 23 | return 0; 24 | return new (std::nothrow) char[bytes]; 25 | } 26 | static void free BOOST_PREVENT_MACRO_SUBSTITUTION(char * const block) 27 | { 28 | delete [] block; 29 | } 30 | }; 31 | 32 | template 33 | void test_alignment(T) 34 | { 35 | unsigned align = boost::alignment_of::value; 36 | boost::pool<> p(sizeof(T)); 37 | unsigned limit = 100000; 38 | for(unsigned i = 0; i < limit; ++i) 39 | { 40 | void* ptr = (p.malloc)(); 41 | BOOST_TEST(reinterpret_cast(ptr) % align == 0); 42 | // Trample over the memory just to be sure the allocated block is big enough, 43 | // if it's not, we'll trample over the next block as well (and our internal housekeeping). 44 | std::memset(ptr, 0xff, sizeof(T)); 45 | } 46 | } 47 | 48 | 49 | int main() 50 | { 51 | boost::pool po(1501); 52 | void* p = (po.malloc)(); 53 | BOOST_TEST(p != 0); 54 | 55 | test_alignment(char(0)); 56 | test_alignment(short(0)); 57 | test_alignment(int(0)); 58 | test_alignment(long(0)); 59 | test_alignment(double(0)); 60 | test_alignment(float(0)); 61 | test_alignment((long double)(0)); 62 | #ifndef BOOST_NO_LONG_LONG 63 | test_alignment((long long)(0)); 64 | #endif 65 | return boost::report_errors(); 66 | } 67 | -------------------------------------------------------------------------------- /test/test_bug_2696.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 John Maddock 2 | * 3 | * Use, modification and distribution is subject to the 4 | * Boost Software License, Version 1.0. (See accompanying 5 | * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Test of bug #2696 (https://svn.boost.org/trac/boost/ticket/2696) 9 | 10 | #include 11 | #include 12 | 13 | struct limited_allocator_new_delete 14 | { 15 | typedef std::size_t size_type; 16 | typedef std::ptrdiff_t difference_type; 17 | 18 | static char * malloc BOOST_PREVENT_MACRO_SUBSTITUTION(const size_type bytes) 19 | { 20 | #ifndef BOOST_POOL_VALGRIND 21 | static const unsigned max_size = sizeof(void*) * 40 + boost::integer::static_lcm::value + sizeof(size_type); 22 | #else 23 | static const unsigned max_size = sizeof(void*) * 40; 24 | #endif 25 | if(bytes > max_size) 26 | return 0; 27 | return new (std::nothrow) char[bytes]; 28 | } 29 | static void free BOOST_PREVENT_MACRO_SUBSTITUTION(char * const block) 30 | { 31 | delete [] block; 32 | } 33 | }; 34 | 35 | int main() 36 | { 37 | static const unsigned alloc_size = sizeof(void*); 38 | boost::pool p1(alloc_size, 10, 40); 39 | for(int i = 1; i <= 40; ++i) 40 | BOOST_TEST((p1.ordered_malloc)(i)); 41 | BOOST_TEST(p1.ordered_malloc(42) == 0); 42 | // 43 | // If the largest block is 40, and we start with 10, we get 10+20+40 elements before 44 | // we actually run out of memory: 45 | // 46 | boost::pool p2(alloc_size, 10, 40); 47 | for(int i = 1; i <= 70; ++i) 48 | BOOST_TEST((p2.malloc)()); 49 | boost::pool p2b(alloc_size, 10, 40); 50 | for(int i = 1; i <= 100; ++i) 51 | BOOST_TEST((p2b.ordered_malloc)()); 52 | // 53 | // Try again with no explicit upper limit: 54 | // 55 | boost::pool p3(alloc_size); 56 | for(int i = 1; i <= 40; ++i) 57 | BOOST_TEST((p3.ordered_malloc)(i)); 58 | BOOST_TEST(p3.ordered_malloc(42) == 0); 59 | boost::pool p4(alloc_size, 10); 60 | for(int i = 1; i <= 100; ++i) 61 | BOOST_TEST((p4.ordered_malloc)()); 62 | boost::pool p5(alloc_size, 10); 63 | for(int i = 1; i <= 100; ++i) 64 | BOOST_TEST((p5.malloc)()); 65 | return boost::report_errors(); 66 | } 67 | -------------------------------------------------------------------------------- /test/test_bug_3349.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 Kwan Ting Chan 2 | * Based from bug report submitted by Xiaohan Wang 3 | * 4 | * Use, modification and distribution is subject to the 5 | * Boost Software License, Version 1.0. (See accompanying 6 | * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 7 | */ 8 | 9 | // Test of bug #3349 (https://svn.boost.org/trac/boost/ticket/3349) 10 | 11 | #include 12 | 13 | #include 14 | 15 | int main() 16 | { 17 | boost::pool<> p(256, 4); 18 | 19 | void* pBlock1 = p.ordered_malloc( 1 ); 20 | void* pBlock2 = p.ordered_malloc( 4 ); 21 | (void)pBlock2; // warning suppression 22 | 23 | p.ordered_free( pBlock1 ); 24 | 25 | BOOST_TEST(p.release_memory()); 26 | return boost::report_errors(); 27 | } 28 | -------------------------------------------------------------------------------- /test/test_bug_4960.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 Kwan Ting Chan 2 | * Based from bug report submitted by Xiaohan Wang 3 | * 4 | * Use, modification and distribution is subject to the 5 | * Boost Software License, Version 1.0. (See accompanying 6 | * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 7 | */ 8 | 9 | // Test of bug #4960 (https://svn.boost.org/trac/boost/ticket/4960) 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | typedef std::vector > EventVector; 16 | typedef std::vector > IndexVector; 17 | 18 | int main() 19 | { 20 | IndexVector iv; 21 | int limit = 100; 22 | for (int i = 0; i < limit; ++i) 23 | { 24 | iv.push_back(EventVector()); 25 | for(int j = 0; j < limit; ++j) 26 | iv.back().push_back(j); 27 | } 28 | 29 | boost::pool po(4); 30 | for(int i = 0; i < limit; ++i) 31 | { 32 | void* p = po.ordered_malloc(0); 33 | po.ordered_free(p, 0); 34 | } 35 | 36 | boost::pool_allocator al; 37 | for(int i = 0; i < limit; ++i) 38 | { 39 | int* p = al.allocate(0); 40 | al.deallocate(p, 0); 41 | } 42 | 43 | std::cout << "it works\n"; 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /test/test_bug_5526.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 John Maddock 2 | * 3 | * Use, modification and distribution is subject to the 4 | * Boost Software License, Version 1.0. (See accompanying 5 | * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Test of bug #5526 (https://svn.boost.org/trac/boost/ticket/5526) 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | struct bad 16 | { 17 | bad() 18 | { 19 | buf = static_cast(boost::singleton_pool::malloc()); 20 | *buf = 0x1234; 21 | } 22 | ~bad() 23 | { 24 | BOOST_ASSERT(*buf == 0x1234); 25 | boost::singleton_pool::free(buf); 26 | } 27 | int* buf; 28 | }; 29 | 30 | boost::scoped_ptr aptr; 31 | 32 | int main() 33 | { 34 | aptr.reset(new bad()); 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /test/test_bug_6701.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2012 Étienne Dupuis 2 | * 3 | * Use, modification and distribution is subject to the 4 | * Boost Software License, Version 1.0. (See accompanying 5 | * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Test of bug #6701 (https://svn.boost.org/trac/boost/ticket/6701) 9 | 10 | #include 11 | #include 12 | 13 | int main() 14 | { 15 | boost::pool<> p(1024, std::numeric_limits::max() / 768); 16 | 17 | void *x = p.malloc(); 18 | if (sizeof(size_t) > 4) 19 | BOOST_ASSERT(!x); 20 | 21 | BOOST_ASSERT(std::numeric_limits::max() / 1024 >= p.get_next_size()); 22 | BOOST_ASSERT(std::numeric_limits::max() / 1024 >= p.get_max_size()); 23 | 24 | void *y = p.ordered_malloc(std::numeric_limits::max() / 768); 25 | if (sizeof(size_t) > 4) 26 | BOOST_ASSERT(!y); 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /test/test_msvc_mem_leak_detect.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 Kwan Ting Chan 2 | * 3 | * Use, modification and distribution is subject to the 4 | * Boost Software License, Version 1.0. (See accompanying 5 | * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Test of bug #4346 (https://svn.boost.org/trac/boost/ticket/4346) 9 | 10 | #ifdef _MSC_VER 11 | #define _CRTDBG_MAP_ALLOC 12 | #include 13 | #include 14 | #endif 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | struct Foo {}; 26 | 27 | int main() 28 | { 29 | { 30 | boost::pool<> p(sizeof(int)); 31 | (p.malloc)(); 32 | } 33 | 34 | { 35 | boost::object_pool p; 36 | (p.malloc)(); 37 | } 38 | 39 | { 40 | (boost::singleton_pool::malloc)(); 41 | } 42 | boost::singleton_pool::purge_memory(); 43 | 44 | { 45 | std::vector > v; 46 | v.push_back(8); 47 | } 48 | boost::singleton_pool::release_memory(); 50 | } 51 | -------------------------------------------------------------------------------- /test/test_poisoned_macros.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 John Maddock 2 | * 3 | * Use, modification and distribution is subject to the 4 | * Boost Software License, Version 1.0. (See accompanying 5 | * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // 9 | // Verify that if malloc/free are macros that everything still works OK: 10 | // 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | namespace std{ 23 | 24 | void* undefined_poisoned_symbol1(unsigned x); 25 | void undefined_poisoned_symbol2(void* x); 26 | 27 | } 28 | 29 | #define malloc(x) undefined_poisoned_symbol1(x) 30 | #define free(x) undefined_poisoned_symbol2(x) 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | template class boost::object_pool; 38 | template class boost::object_pool; 39 | 40 | template class boost::pool; 41 | template class boost::pool; 42 | 43 | template class boost::pool_allocator; 44 | template class boost::pool_allocator; 45 | template class boost::fast_pool_allocator; 46 | template class boost::fast_pool_allocator; 47 | 48 | template class boost::simple_segregated_storage; 49 | 50 | template class boost::singleton_pool; 51 | -------------------------------------------------------------------------------- /test/test_simple_seg_storage.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2000, 2001 Stephen Cleary 2 | * Copyright (C) 2011 Kwan Ting Chan 3 | * 4 | * Use, modification and distribution is subject to the 5 | * Boost Software License, Version 1.0. (See accompanying 6 | * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 7 | */ 8 | 9 | #ifndef BOOST_POOL_TEST_SIMP_SEG_STORE_HPP 10 | #define BOOST_POOL_TEST_SIMP_SEG_STORE_HPP 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | class test_simp_seg_store : public boost::simple_segregated_storage 25 | { 26 | private: 27 | // ::first is the address of the start of the added block, 28 | // ::second is the size in bytes of the added block 29 | std::vector > allocated_blocks; 30 | size_type np_sz; 31 | std::set allocated_chunks; 32 | 33 | void set_partition_size(const size_type sz) 34 | { 35 | if(allocated_blocks.empty()) 36 | { 37 | np_sz = sz; 38 | } 39 | else 40 | { 41 | BOOST_ASSERT(np_sz == sz); 42 | } 43 | } 44 | 45 | // Return: true if chunk is from added blocks, false otherwise 46 | bool is_inside_allocated_blocks(void* const chunk) const 47 | { 48 | typedef std::vector >::const_iterator 49 | VPIter; 50 | for(VPIter iter = allocated_blocks.begin(); 51 | iter != allocated_blocks.end(); 52 | ++iter) 53 | { 54 | if( std::less_equal()(iter->first, chunk) 55 | && std::less_equal()(static_cast(chunk) + np_sz, 56 | static_cast(iter->first) + iter->second) ) 57 | { 58 | return true; 59 | } 60 | } 61 | 62 | return false; 63 | } 64 | 65 | void check_in(void* const chunk) 66 | { 67 | // Check that the newly allocated chunk has not already previously 68 | // been allocated, and that the memory does not overlap with 69 | // previously allocated chunks 70 | for(std::set::const_iterator iter = allocated_chunks.begin(); 71 | iter != allocated_chunks.end(); 72 | ++iter) 73 | { 74 | BOOST_TEST( std::less_equal()(static_cast(chunk) 75 | + np_sz, *iter) 76 | || std::less_equal()(static_cast(*iter) 77 | + np_sz, chunk) ); 78 | } 79 | 80 | allocated_chunks.insert(chunk); 81 | } 82 | 83 | void check_out(void* const chunk) 84 | { 85 | BOOST_TEST(allocated_chunks.erase(chunk) == 1); 86 | } 87 | 88 | public: 89 | test_simp_seg_store() 90 | : np_sz(0) {} 91 | 92 | void* get_first() { return first; } 93 | static void*& get_nextof(void* const ptr) { return nextof(ptr); } 94 | 95 | // (Test) Pre: npartition_sz of all added block is the same 96 | // different blocks of memory does not overlap 97 | void add_block(void* const block, 98 | const size_type nsz, const size_type npartition_sz) 99 | { 100 | set_partition_size(npartition_sz); 101 | allocated_blocks.push_back( 102 | std::pair(block, nsz) ); 103 | boost::simple_segregated_storage::add_block( 104 | block, nsz, npartition_sz ); 105 | // Post: !empty() 106 | BOOST_TEST(!empty()); 107 | } 108 | 109 | // (Test) Pre: npartition_sz of all added block is the same 110 | // different blocks of memory does not overlap 111 | void add_ordered_block(void* const block, 112 | const size_type nsz, const size_type npartition_sz) 113 | { 114 | set_partition_size(npartition_sz); 115 | allocated_blocks.push_back( 116 | std::pair(block, nsz) ); 117 | boost::simple_segregated_storage::add_ordered_block( 118 | block, nsz, npartition_sz ); 119 | // Post: !empty() 120 | BOOST_TEST(!empty()); 121 | } 122 | 123 | void* malloc() 124 | { 125 | void* const ret 126 | = boost::simple_segregated_storage::malloc(); 127 | // Chunk returned should actually be from added blocks 128 | BOOST_TEST(is_inside_allocated_blocks(ret)); 129 | check_in(ret); 130 | return ret; 131 | } 132 | 133 | void free(void* const chunk) 134 | { 135 | BOOST_ASSERT(chunk); 136 | check_out(chunk); 137 | boost::simple_segregated_storage::free(chunk); 138 | // Post: !empty() 139 | BOOST_TEST(!empty()); 140 | } 141 | 142 | void ordered_free(void* const chunk) 143 | { 144 | BOOST_ASSERT(chunk); 145 | check_out(chunk); 146 | boost::simple_segregated_storage::ordered_free(chunk); 147 | // Post: !empty() 148 | BOOST_TEST(!empty()); 149 | } 150 | 151 | void* malloc_n(size_type n, size_type partition_size) 152 | { 153 | void* const ret 154 | = boost::simple_segregated_storage::malloc_n( 155 | n, partition_size ); 156 | 157 | if(ret) 158 | { 159 | for(std::size_t i=0; i < n; ++i) 160 | { 161 | void* const chunk = static_cast(ret) 162 | + (i * partition_size); 163 | // Memory returned should actually be from added blocks 164 | BOOST_TEST(is_inside_allocated_blocks(chunk)); 165 | check_in(chunk); 166 | } 167 | } 168 | 169 | return ret; 170 | } 171 | }; 172 | 173 | #endif // BOOST_POOL_TEST_SIMP_SEG_STORE_HPP 174 | -------------------------------------------------------------------------------- /test/test_threading.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 John Maddock 2 | * 3 | * Use, modification and distribution is subject to the 4 | * Boost Software License, Version 1.0. (See accompanying 5 | * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #if defined(BOOST_MSVC) && (BOOST_MSVC <= 1600) 12 | #pragma warning(push) 13 | #pragma warning(disable: 4244) 14 | // ..\..\boost/random/uniform_int_distribution.hpp(171) : 15 | // warning C4127: conditional expression is constant 16 | #pragma warning(disable: 4127) 17 | // ..\..\boost/random/detail/polynomial.hpp(315) : 18 | // warning C4267: 'argument' : conversion from 'size_t' 19 | // to 'int', possible loss of data 20 | #pragma warning(disable: 4267) 21 | #endif 22 | #include 23 | #include 24 | #if defined(BOOST_MSVC) && (BOOST_MSVC <= 1600) 25 | #pragma warning(pop) 26 | #endif 27 | 28 | void run_tests() 29 | { 30 | boost::random::mt19937 gen; 31 | boost::random::uniform_int_distribution<> dist(-10, 10); 32 | std::list > l; 33 | 34 | for(int i = 0; i < 100; ++i) 35 | l.push_back(i); 36 | 37 | for(int i = 0; i < 20000; ++i) 38 | { 39 | int val = dist(gen); 40 | if(val < 0) 41 | { 42 | while(val && l.size()) 43 | { 44 | l.pop_back(); 45 | ++val; 46 | } 47 | } 48 | else 49 | { 50 | while(val) 51 | { 52 | l.push_back(val); 53 | --val; 54 | } 55 | } 56 | } 57 | } 58 | 59 | int main() 60 | { 61 | std::list > threads; 62 | for(int i = 0; i < 10; ++i) 63 | { 64 | try{ 65 | threads.push_back(boost::shared_ptr(new boost::thread(&run_tests))); 66 | } 67 | catch(const std::exception& e) 68 | { 69 | std::cerr << "Thread creation failed with message: " << e.what() << "" << std::endl; 70 | } 71 | } 72 | std::list >::const_iterator a(threads.begin()), b(threads.end()); 73 | while(a != b) 74 | { 75 | (*a)->join(); 76 | ++a; 77 | } 78 | return 0; 79 | } 80 | 81 | -------------------------------------------------------------------------------- /test/test_valgrind_fail_1.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 John Maddock 2 | * 3 | * Use, modification and distribution is subject to the 4 | * Boost Software License, Version 1.0. (See accompanying 5 | * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Test of bug #2656 (https://svn.boost.org/trac/boost/ticket/2656) 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | static const int magic_value = 0x12345678; 15 | 16 | int main() 17 | { 18 | boost::pool<> p(sizeof(int)); 19 | int* ptr = static_cast((p.malloc)()); 20 | std::cout << *ptr << std::endl; // uninitialized read 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /test/test_valgrind_fail_2.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 John Maddock 2 | * 3 | * Use, modification and distribution is subject to the 4 | * Boost Software License, Version 1.0. (See accompanying 5 | * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Test of bug #2656 (https://svn.boost.org/trac/boost/ticket/2656) 9 | 10 | #include 11 | 12 | int main() 13 | { 14 | boost::pool<> p(sizeof(int)); 15 | int* ptr = static_cast((p.malloc)()); 16 | *ptr = 0; 17 | (p.free)(ptr); 18 | *ptr = 2; // write to freed memory 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /test/track_allocator.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2000, 2001 Stephen Cleary 2 | * Copyright (C) 2011 Kwan Ting Chan 3 | * 4 | * Use, modification and distribution is subject to the 5 | * Boost Software License, Version 1.0. (See accompanying 6 | * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 7 | */ 8 | 9 | #ifndef BOOST_POOL_TRACK_ALLOCATOR_HPP 10 | #define BOOST_POOL_TRACK_ALLOCATOR_HPP 11 | 12 | #include 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | 20 | // Each "tester" object below checks into and out of the "cdtor_checker", 21 | // which will check for any problems related to the construction/destruction of 22 | // "tester" objects. 23 | class cdtor_checker 24 | { 25 | private: 26 | // Each constructed object registers its "this" pointer into "objs" 27 | std::set objs; 28 | 29 | public: 30 | // True iff all objects that have checked in have checked out 31 | bool ok() const { return objs.empty(); } 32 | 33 | ~cdtor_checker() 34 | { 35 | BOOST_TEST(ok()); 36 | } 37 | 38 | void check_in(void * const This) 39 | { 40 | BOOST_TEST(objs.find(This) == objs.end()); 41 | objs.insert(This); 42 | } 43 | 44 | void check_out(void * const This) 45 | { 46 | BOOST_TEST(objs.find(This) != objs.end()); 47 | objs.erase(This); 48 | } 49 | }; 50 | static cdtor_checker mem; 51 | 52 | struct tester 53 | { 54 | tester(bool throw_except = false) 55 | { 56 | if(throw_except) 57 | { 58 | throw std::logic_error("Deliberate constructor exception"); 59 | } 60 | 61 | mem.check_in(this); 62 | } 63 | 64 | tester(const tester &) 65 | { 66 | mem.check_in(this); 67 | } 68 | 69 | ~tester() 70 | { 71 | mem.check_out(this); 72 | } 73 | }; 74 | 75 | // Allocator that registers alloc/dealloc to/from the system memory 76 | struct track_allocator 77 | { 78 | typedef std::size_t size_type; 79 | typedef std::ptrdiff_t difference_type; 80 | 81 | static std::set allocated_blocks; 82 | 83 | static char* malloc(const size_type bytes) 84 | { 85 | char* const ret = new (std::nothrow) char[bytes]; 86 | allocated_blocks.insert(ret); 87 | return ret; 88 | } 89 | 90 | static void free(char* const block) 91 | { 92 | BOOST_TEST(allocated_blocks.find(block) != allocated_blocks.end()); 93 | allocated_blocks.erase(block); 94 | delete [] block; 95 | } 96 | 97 | static bool ok() 98 | { 99 | return allocated_blocks.empty(); 100 | } 101 | }; 102 | std::set track_allocator::allocated_blocks; 103 | 104 | #endif // BOOST_POOL_TRACK_ALLOCATOR_HPP 105 | -------------------------------------------------------------------------------- /test/valgrind_config_check.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | int main() 5 | { 6 | return 0; 7 | } --------------------------------------------------------------------------------