2013/4/14 TONGARI
2013/4/14 Christian Henning
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 parameter align_in_bytes. When deallocate, you can use _capacity without recomputing the total_allocated_size_in_bytes.
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?
Well, after a deeper look, some ctors need _align_in_bytes from another image... if you don't care an extra data member, it's still doable. Or maybe I should cook me own :(
Thanks