Boost logo

Boost :

From: scleary_at_[hidden]
Date: 2001-05-03 10:16:29


> > But note that my solution is able to side-step this issue because Pool
> > doesn't keep *any* information about allocated chunks. Your problem can
use
> > a similar solution, but only if you go to a footer instead of a header,
>
> That won't work. The information stored in the header is:
>
> 1) a link to the next block
> 2) a pointer to a shape descriptor
> 3) a flag for use in the mark/sweep phase of collection
>
> The shape descriptor consists of:
>
> 1) the size of the block
> 2) a finalisation routine
> 3) the number of managed pointers
> 4) offsets to the managed pointers
>
> So you see that the only way to find the size of the block,
> so as to locate the footer, is to already know the address
> of the footer so as to get the shape descriptor, and thus
> the size of the block :-)

If you look at my implementation, the link to the next block actually points
to the next block's link to *it's* next block (i.e., it points into the
footer of the next block). So you can work backwards from the "next block's
link to it's next block" into the "next block's pointer for it's shape
descriptor", and get the size of the next block from that. Twisted, but it
should work :)

This will *not* work, though, if you ever wanted to allow the user to
deallocate a block (since, as you pointed out, you can't find the footer
without an expensive list search).

        -Steve


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk