Le 11/04/2018 à 09:02, Dimitri Vorona a écrit :
> Hi everybody,
> to continue the discussion in : right now this  can happen and the
> sliced buffer has no way to foresee or to check against it beforehand.
> I'd suggest to create a new class SlicedBuffer, which would reference the
> parent buffer and return it's data() pointer, insted of grabbing the
> pointer at creation. We can the parent reference a weak pointer, so the
> existing SliceBuffers don't prevent the deallocation (or maybe even have a
> separate WeakSliceBuffer class).
AFAIU, the problem only exists with ResizableBuffer?
We could do the following:
- add a new Buffer member counting the number of exports (default 0)
- in SliceBuffer, increment the parent's number of exports
- in ~Buffer, decrement the parent's number of exports
- in PoolBuffer::Resize(), return an error if the buffer has any exports
(this is how Python buffers work, for the record)
What do you think?