Boost logo

Boost Users :

From: Filip Konvička (filip.konvicka_at_[hidden])
Date: 2007-09-25 14:19:55


Cory Nelson 7.9.2007 5:13:
> 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?
I would also like to hear a comment from Stephen. Anyway, reading
through "concepts" in pool docs, it seems that the least common multiple
is used to ensure proper alignment (if you ever got a SIGBUS, you'll
want to avoid unaligned memory access). So beware....

Cheers,
Filip


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