Re: [swift-users] How much memory does withMemoryRebound bind

2017-01-04 Thread Andrew Trick via swift-users
> On Dec 29, 2016, at 2:03 PM, Guillaume Lessard via swift-users > wrote: > > Hi Etan, > > `withMemoryRebound` does not copy memory. > The proposal for UnsafeRawPointer contains information about the memory model > (as related to pointers): > https://github.com/apple/swift-evolution/blob/mast

Re: [swift-users] How much memory does withMemoryRebound bind

2017-01-03 Thread Etan Kissling via swift-users
Thank you very much! > On 29 Dec 2016, at 23:03, Guillaume Lessard via swift-users > wrote: > > Hi Etan, > > `withMemoryRebound` does not copy memory. > The proposal for UnsafeRawPointer contains information about the memory model > (as related to pointers): > https://github.com/apple/swift-

Re: [swift-users] How much memory does withMemoryRebound bind

2016-12-29 Thread Guillaume Lessard via swift-users
Hi Etan, `withMemoryRebound` does not copy memory. The proposal for UnsafeRawPointer contains information about the memory model (as related to pointers): https://github.com/apple/swift-evolution/blob/master/proposals/0107-unsaferawpointer.md (also, the method is defined in the following file: h

Re: [swift-users] How much memory does withMemoryRebound bind

2016-12-29 Thread Etan Kissling via swift-users
Thanks once more! It all depends on how withMemoryRebound works. If there is any way where it actually copies the bound memory to a separate place, then passes that copy to the closure, it would not be a good idea to write past the end of the bound memory. If withMemoryRebound is a simple cast

Re: [swift-users] How much memory does withMemoryRebound bind

2016-12-29 Thread Rien via swift-users
Ah, ok. In that case, I believe it is correct because sockaddr_storage is in fact big enough to hold either the IPv4 or IPv6 structure. When bits go unused, that causes no harm. And when “addr” goes out of scope, it will be completely deallocated, so no memory leak either. Regards, Rien Site:

Re: [swift-users] How much memory does withMemoryRebound bind

2016-12-29 Thread Etan Kissling via swift-users
I meant the question in a more generalized sense. The sockaddr example is just one that is easily understandable :-) Thanks for the link though, interesting read! > On 29 Dec 2016, at 14:47, Rien wrote: > > I used the code from > http://blog.obdev.at/representing-socket-addresses-in-swift-usi

Re: [swift-users] How much memory does withMemoryRebound bind

2016-12-29 Thread Rien via swift-users
I used the code from http://blog.obdev.at/representing-socket-addresses-in-swift-using-enums/ in my package SwifterSockets (see github link below) It does not answer your question exactly, but I think it is a rather better approach to sockaddr usage. Regards, Rien Site: http://balancingrock.n