> 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
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-
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
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
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:
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
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