Hi Philippe,
Thank you for your response!
> On Dec 9, 2016, at 8:44 AM, Philippe Hausler <phaus...@apple.com> wrote:
>
> So letting the bytes escape from the closure could potentially be in that
> territory of “bad things may happen”. If you know for certain that the Data
> will not be mutated and it’s underlying storage will last for the duration of
> the usage then you should be able to get away with it.
>
So far it is looking like I am getting away with it. I believe the conditions
that you state hold.
> The bytes pointer is an inner pointer return from the encapsulating object
> backing the struct Data. Since that backing object can potentially be
> deallocated via mutation or the buffer may be reallocated (which very often
> can cause the base address of the pointer to change) we decided it would be
> safer to use a closure to ensure the lifespan of the bytes over the access to
> the bytes.
>
> Perhaps it might be best to understand more of what you are trying to do to
> offer a better solution.
I am trying to use the compression_stream C API in the Compression framework
and wrap it so it is a bit more Swifty. :]
A full gist of the playground is here:
https://gist.github.com/rayfix/a286bb55accffef09249ba3535993782
<https://gist.github.com/rayfix/a286bb55accffef09249ba3535993782>
See line 91.
Appreciate the hints.
Ray
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users