|
Boost Users : |
Subject: Re: [Boost-users] boost::pool
From: strasser_at_[hidden]
Date: 2009-11-05 13:53:16
Zitat von Jonathan Franklin <franklin.jonathan_at_[hidden]>:
> On Thu, Nov 5, 2009 at 9:31 AM, Roman Shmelev <rshmelev_at_[hidden]> wrote:
>> I want the following type of pool in the wishlist:
>> Allowing to allocate misc-size memory blocks without an ability to
>> delete them (I mean they will are deleted on pool destruction).
>> I met some situations where such pool was really what needed.
>
> I actually did this at one time w/ the boost::pool by making my
> requested_size 1 byte, then doing an ordered_malloc(num_bytes).
>
> I'm not claiming that this is a good or a bad idea. But it did work.
>
I think roman's point was the automatic destruction of different
object types on pool destruction.
an implementation of that would e.g. look like this:
struct object_base{
virtual ~object_base() = 0;
virtual object_base *next() = 0;
};
template<class T>
struct object : object_base{
T user_object;
virtual ~object(){}
virtual object_base *next(); //returns this + 1 and takes care of alignment
};
with new objects just added to the end of the block.
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