test_bug_4960.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. // Test of bug #4960 (https://svn.boost.org/trac/boost/ticket/4960)
  9. #include <boost/pool/pool_alloc.hpp>
  10. #include <vector>
  11. #include <iostream>
  12. typedef std::vector<int, boost::pool_allocator<int> > EventVector;
  13. typedef std::vector<EventVector, boost::pool_allocator<EventVector> > IndexVector;
  14. int main()
  15. {
  16. IndexVector iv;
  17. int limit = 100;
  18. for (int i = 0; i < limit; ++i)
  19. {
  20. iv.push_back(EventVector());
  21. for(int j = 0; j < limit; ++j)
  22. iv.back().push_back(j);
  23. }
  24. boost::pool<boost::default_user_allocator_new_delete> po(4);
  25. for(int i = 0; i < limit; ++i)
  26. {
  27. void* p = po.ordered_malloc(0);
  28. po.ordered_free(p, 0);
  29. }
  30. boost::pool_allocator<int> al;
  31. for(int i = 0; i < limit; ++i)
  32. {
  33. int* p = al.allocate(0);
  34. al.deallocate(p, 0);
  35. }
  36. std::cout << "it works\n";
  37. return 0;
  38. }