Subject: Re: [boost] [GIL] Can image::recreate reuse the memory?
From: TONGARI (tongari95_at_[hidden])
Date: 2013-04-13 23:39:18
2013/4/14 Christian Henning <chhenning_at_[hidden]>
> > I'd expect image::recreate to reuse the memory much like
> > std::vector::resize, but looked into the code shows that it creates a new
> > one and swaps...
> > So, is there a way to 'resize' the image without reallocating if the
> > internal memory is sufficient?
> I afraid there is not a way right now. Do you have a quick fix or would
> such behavior be more complicated?
You can replace the data member '_align_in_bytes' with, say, _capacity.
And make those member functions which use _align_in_bytes accept an extra
When deallocate, you can use _capacity without recomputing the
As to recreate, you can compute total_allocated_size_in_bytes which gives
you the new capacity and compare it with the old _capacity to decide
reallocate or not.
Just a quick thought, maybe something I missed?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk