Boost logo

Boost Users :

From: Cory Nelson (phrosty_at_[hidden])
Date: 2007-09-06 23:13:54


On 9/6/07, 蹬三轮的 <tricycle_at_[hidden]> wrote:
> According to the description of pool, it should be working like you
> said. But actually it is not the same. Hereby, there are two cases
> provided.
> I think you will find two totally different results between them.

Okay, I have found the problem. pool::alloc_size seems to be a least
common multiple of sizeof(void*) and your chunk size.

Assuming sizeof(void*) is 4,
In the case of 1316, this comes to 1316. In the case of 1317, this
comes to 5268, or 4 times the requested size which is what you are
seeing. This seems incorrect.

I have not tested this, but on line 183 of boost/pool/pool.hpp, change

return details::pool::lcm<size_type>(requested_size, min_size);

to:

return std::max(requested_size + (min_size - 1) & ~(min_size - 1), min_size);

This should fix your size problem while still keeping the size aligned
on pointer-sized boundaries, which I believe was the original
intention of the author. Does Stephen Cleary even monitor this list
to comment?

-- 
Cory Nelson

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net