<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hi Philippe,</div><div class=""><br class=""></div><div class="">Thank you for your response!</div><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 9, 2016, at 8:44 AM, Philippe Hausler &lt;<a href="mailto:phausler@apple.com" class="">phausler@apple.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">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.</div><div class=""><br class=""></div></div></div></blockquote><div><br class=""></div><div>So far it is looking like I am getting away with it. I believe the conditions that you state hold.</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">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.</div><div class=""><br class=""></div><div class="">Perhaps it might be best to understand more of what you are trying to do to offer a better solution.</div></div></div></blockquote><div><br class=""></div><div>I am trying to use the compression_stream C API in the Compression framework and wrap it so it is a bit more Swifty. &nbsp;:]</div><div><br class=""></div><div>A full gist of the playground is here:&nbsp;<a href="https://gist.github.com/rayfix/a286bb55accffef09249ba3535993782" class="">https://gist.github.com/rayfix/a286bb55accffef09249ba3535993782</a></div><div><br class=""></div><div>See line 91.</div><div><br class=""></div><div>Appreciate the hints.&nbsp;</div><div><br class=""></div><div>Ray</div></div></body></html>