/[packages]/cauldron/mariadb/current/SOURCES/boost-1.50.0-pool.patch
ViewVC logotype

Contents of /cauldron/mariadb/current/SOURCES/boost-1.50.0-pool.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 474203 - (show annotations) (download)
Mon Sep 2 00:32:22 2013 UTC (10 years, 7 months ago) by alien
File size: 4794 byte(s)
- Use internal boost 1.53
- add extra sphinx plugin
- add forgotten man page
- remove solaris specific files
1 Index: boost/pool/pool.hpp
2 ===================================================================
3 --- boost/pool/pool.hpp (revision 78317)
4 +++ boost/pool/pool.hpp (revision 78326)
5 @@ -27,4 +27,6 @@
6 #include <boost/pool/poolfwd.hpp>
7
8 +// std::numeric_limits
9 +#include <boost/limits.hpp>
10 // boost::math::static_lcm
11 #include <boost/math/common_factor_ct.hpp>
12 @@ -358,4 +360,13 @@
13 }
14
15 + size_type max_chunks() const
16 + { //! Calculated maximum number of memory chunks that can be allocated in a single call by this Pool.
17 + size_type partition_size = alloc_size();
18 + size_type POD_size = math::static_lcm<sizeof(size_type), sizeof(void *)>::value + sizeof(size_type);
19 + size_type max_chunks = (std::numeric_limits<size_type>::max() - POD_size) / alloc_size();
20 +
21 + return max_chunks;
22 + }
23 +
24 static void * & nextof(void * const ptr)
25 { //! \returns Pointer dereferenced.
26 @@ -377,5 +388,7 @@
27 //! the first time that object needs to allocate system memory.
28 //! The default is 32. This parameter may not be 0.
29 - //! \param nmax_size is the maximum number of chunks to allocate in one block.
30 + //! \param nmax_size is the maximum number of chunks to allocate in one block.
31 + set_next_size(nnext_size);
32 + set_max_size(nmax_size);
33 }
34
35 @@ -400,7 +413,7 @@
36 }
37 void set_next_size(const size_type nnext_size)
38 - { //! Set number of chunks to request from the system the next time that object needs to allocate system memory. This value should never be set to 0.
39 - //! \returns nnext_size.
40 - next_size = start_size = nnext_size;
41 + { //! Set number of chunks to request from the system the next time that object needs to allocate system memory. This value should never be set to 0.
42 + BOOST_USING_STD_MIN();
43 + next_size = start_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(nnext_size, max_chunks());
44 }
45 size_type get_max_size() const
46 @@ -410,5 +423,6 @@
47 void set_max_size(const size_type nmax_size)
48 { //! Set max_size.
49 - max_size = nmax_size;
50 + BOOST_USING_STD_MIN();
51 + max_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(nmax_size, max_chunks());
52 }
53 size_type get_requested_size() const
54 @@ -713,7 +727,7 @@
55 BOOST_USING_STD_MIN();
56 if(!max_size)
57 - next_size <<= 1;
58 + set_next_size(next_size << 1);
59 else if( next_size*partition_size/requested_size < max_size)
60 - next_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size*requested_size/ partition_size);
61 + set_next_size(min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size * requested_size / partition_size));
62
63 // initialize it,
64 @@ -753,7 +767,7 @@
65 BOOST_USING_STD_MIN();
66 if(!max_size)
67 - next_size <<= 1;
68 + set_next_size(next_size << 1);
69 else if( next_size*partition_size/requested_size < max_size)
70 - next_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size*requested_size/ partition_size);
71 + set_next_size(min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size * requested_size / partition_size));
72
73 // initialize it,
74 @@ -797,4 +811,6 @@
75 //! \returns Address of chunk n if allocated ok.
76 //! \returns 0 if not enough memory for n chunks.
77 + if (n > max_chunks())
78 + return 0;
79
80 const size_type partition_size = alloc_size();
81 @@ -845,7 +861,7 @@
82 BOOST_USING_STD_MIN();
83 if(!max_size)
84 - next_size <<= 1;
85 + set_next_size(next_size << 1);
86 else if( next_size*partition_size/requested_size < max_size)
87 - next_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size*requested_size/ partition_size);
88 + set_next_size(min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size * requested_size / partition_size));
89
90 // insert it into the list,
91 Index: libs/pool/test/test_bug_6701.cpp
92 ===================================================================
93 --- libs/pool/test/test_bug_6701.cpp (revision 78326)
94 +++ libs/pool/test/test_bug_6701.cpp (revision 78326)
95 @@ -0,0 +1,27 @@
96 +/* Copyright (C) 2012 Étienne Dupuis
97 +*
98 +* Use, modification and distribution is subject to the
99 +* Boost Software License, Version 1.0. (See accompanying
100 +* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
101 +*/
102 +
103 +// Test of bug #6701 (https://svn.boost.org/trac/boost/ticket/6701)
104 +
105 +#include <boost/pool/object_pool.hpp>
106 +#include <boost/limits.hpp>
107 +
108 +int main()
109 +{
110 + boost::pool<> p(1024, std::numeric_limits<size_t>::max() / 768);
111 +
112 + void *x = p.malloc();
113 + BOOST_ASSERT(!x);
114 +
115 + BOOST_ASSERT(std::numeric_limits<size_t>::max() / 1024 >= p.get_next_size());
116 + BOOST_ASSERT(std::numeric_limits<size_t>::max() / 1024 >= p.get_max_size());
117 +
118 + void *y = p.ordered_malloc(std::numeric_limits<size_t>::max() / 768);
119 + BOOST_ASSERT(!y);
120 +
121 + return 0;
122 +}

  ViewVC Help
Powered by ViewVC 1.1.30