Hello Boost Pool developers,
I was making some attempts to use boost::simple_segregated_storage by modifying the example.
This example worked.
#include <boost/pool/simple_segregated_storage.hpp>
#include <cstddef>
#include <vector>
#include <cassert>
#include <iostream>
#include <stdexcept>
int main()
{
boost::simple_segregated_storage<std::size_t> storage;
std::vector<char> v1(5120);
storage.add_ordered_block(&v1.front(), v1.size(), 256);
int* j = static_cast<int*>(storage.malloc_n(1, 1024));
if (j == nullptr)
{
throw std::runtime_error{"Contiguous memory trunks not found."};
}
storage.ordered_free_n(j, 1, 1024);
}
But this example did not work.
#include <boost/pool/simple_segregated_storage.hpp>
#include <cstddef>
#include <vector>
#include <cassert>
#include <iostream>
#include <stdexcept>
int main()
{
boost::simple_segregated_storage<std::size_t> storage;
std::vector<char> v1(5120);
storage.add_ordered_block(&v1.front(), v1.size(), 256);
int* j = static_cast<int*>(storage.malloc_n(2, 1024));
if (j == nullptr)
{
throw std::runtime_error{"Contiguous memory trunks not found."};
}
storage.ordered_free_n(j, 2, 1024);
}
If my understanding of boost::simple_segregated_storage from here is correct, the boost::simple_segregated_storage design should either allow or deny both of the examples above (I personally favor denying both of the examples), but not just one worked and the other one did not.
Can you provide some clarifications about the malloc_n method here? Thank you.
Hello Boost Pool developers,
I was making some attempts to use
boost::simple_segregated_storageby modifying the example.This example worked.
But this example did not work.
If my understanding of
boost::simple_segregated_storagefrom here is correct, theboost::simple_segregated_storagedesign should either allow or deny both of the examples above (I personally favor denying both of the examples), but not just one worked and the other one did not.Can you provide some clarifications about the
malloc_nmethod here? Thank you.