|
Boost : |
Subject: Re: [boost] [GIL] Can image::recreate reuse the memory?
From: TONGARI (tongari95_at_[hidden])
Date: 2013-04-14 10:14:38
2013/4/14 TONGARI <tongari95_at_[hidden]>
> 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
> 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
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk