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 <boost/pool/pool_alloc.hpp> 12 #include <vector> 13 #include <iostream> 14 15 typedef std::vector<int, boost::pool_allocator<int> > EventVector; 16 typedef std::vector<EventVector, boost::pool_allocator<EventVector> > IndexVector; 17 main()18int 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<boost::default_user_allocator_new_delete> 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<int> 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