tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: RFC: Constant Database Support

On Thu, Mar 04, 2010 at 09:52:05PM +0000, Christos Zoulas wrote:
> >Yes. It might be useful to free it for the dup case, but I wouldn't
> >bother freeing the memory after the database is written, given that the
> >program will terminate immediate anyway.
> At least add a comment saying that you need to keep the memory around
> until the database is written.

Right. Basically there are three options for the write interface:
(1) Always copy data / keys, free on close.
(2) Require caller to keep the memory alive until close.
(3) Hand over ownership on add.

The cleanest interface is the first, but it naturally requires (at least
temporary) more memory. The second has the smallest overhead in this
regard, but places the burden on the caller. The third makes use of
constants as keys more work as it requires the caller to do the copying.
At the moment the second option is implemented, but based on some more
reviews of potential users, it seems like (1) is the best option. If the
concerns for the temporary copies are high, (1) and (3) could be
combined, but I don't think it is worth the hassle.


Home | Main Index | Thread Index | Old Index