<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="">Tony, Andrew,</div><div class=""><br class=""></div>Here it is.<div class=""><br class=""></div><div class=""><a href="https://bugs.swift.org/browse/SR-2468" class="">https://bugs.swift.org/browse/SR-2468</a></div><div class=""><br class=""></div><div class="">On Radar as well.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class=""><br class=""></div><div class="">Stéphane</div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On 24 Aug 2016, at 00:32, Tony Parker &lt;<a href="mailto:anthony.parker@apple.com" class="">anthony.parker@apple.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">We should probably add a predefined enum for a deallocator that matches UnsafeMutableRawPointer.allocate. Stéphane or Andy, would you mind filing a JIRA or radar for that?<br class=""><br class="">- Tony<br class=""><br class=""><blockquote type="cite" class="">On Aug 23, 2016, at 9:24 AM, Andrew Trick via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:<br class=""><br class=""><br class=""><blockquote type="cite" class="">On Aug 23, 2016, at 8:40 AM, Stéphane Lizeray via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:<br class=""><br class="">Hello,<br class=""><br class="">I create an UsafeMutableRawPointer using the allocate method.<br class=""><br class="">Later on I want to create a Data struct from this pointer using the bytesNoCopy initializer. Which deallocator should I pass?<br class=""><br class="">It looks like this:<br class=""><br class="">let retPointer = UnsafeMutableRawPointer.allocate(bytes: size, alignedTo: MemoryLayout&lt;UInt8&gt;.alignment)<br class="">….<br class=""><br class="">let d = Data(bytesNoCopy: retPointer, count: size,deallocator:Deallocator.free)<br class=""></blockquote><br class="">Hi Stéphane,<br class=""><br class="">This should work:<br class=""><br class="">let retPointer = UnsafeMutableRawPointer.allocate(bytes: size, alignedTo: MemoryLayout&lt;UInt8&gt;.alignment)<br class=""><br class="">let d = Data(bytesNoCopy: retPointer, count: size, deallocator: .custom({ (ptr, size) in<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;ptr.deallocate(bytes: size, alignedTo: 1)<br class=""> &nbsp;&nbsp;}))<br class=""><br class="">-Andy<br class=""><br class=""><blockquote type="cite" class=""><br class="">Thanks,<br class=""><br class="">Stéphane<br class=""><br class="">_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></blockquote><br class="">_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></blockquote><br class=""></div></div></blockquote></div><br class=""></div></body></html>