Re: [swift-users] C Pointers and Memory

2016-07-30 Thread Bryan Chan via swift-users
Personally I like swiftdoc.org as a reference: http://swiftdoc.org/v3.0/type/UnsafeMutablePointer/ Click on the initializers and function names to read the description of what each of them does. You can use a UnsafeMutableBufferPointer to help initialize your memory (which you have to allocate f

Re: [swift-users] C Pointers and Memory

2016-07-30 Thread Lou Zell via swift-users
On Fri, Jul 29, 2016 at 8:40 PM, Chris McIntyre via swift-users < swift-users@swift.org> wrote: > Hi guys, > > I’m having issues with Swift pointers. I feel like the Interactive With C > APis document only gets you half way there. > > For example, look at this from the docs > > If you have declare

Re: [swift-users] C Pointers and Memory

2016-07-29 Thread Chris McIntyre via swift-users
Hi guys, I’m having issues with Swift pointers. I feel like the Interactive With C APis document only gets you half way there. For example, look at this from the docs If you have declared a function like this one: func takesAMutablePointer(x: UnsafeMutablePointer) { // ... } You can call

Re: [swift-users] C Pointers and Memory

2016-07-29 Thread James Campbell via swift-users
No I haven't thats a big help thank you ! *___* *James⎥Head of Trolls* *ja...@supmenow.com ⎥supmenow.com * *Sup* *Runway East * *10 Finsbury Square* *London* * EC2A 1AF * On 29 July 2016 at 10:40, Zhao Xin wrote: > Have you read > http

Re: [swift-users] C Pointers and Memory

2016-07-29 Thread Zhao Xin via swift-users
Have you read https://developer.apple.com/library/tvos/documentation/Swift/Conceptual/BuildingCocoaApps/InteractingWithCAPIs.html#//apple_ref/doc/uid/TP40014216-CH8-ID17 ? Zhaoxin On Fri, Jul 29, 2016 at 4:55 PM, James Campbell via swift-users < swift-users@swift.org> wrote: > ​Do you know of a

Re: [swift-users] C Pointers and Memory

2016-07-29 Thread James Campbell via swift-users
​Do you know of any resources to brush up on the pointer aspect of swift ? ​ *___* *James⎥Head of Trolls* *ja...@supmenow.com ⎥supmenow.com * *Sup* *Runway East * *10 Finsbury Square* *London* * EC2A 1AF * On 29 July 2016 at 09:10, Dmitr

Re: [swift-users] C Pointers and Memory

2016-07-29 Thread Dmitri Gribenko via swift-users
On Fri, Jul 29, 2016 at 12:55 AM, James Campbell wrote: > So this: > > if let data = someArrayGeneratingFunction() { > cFunction(UnsafeMutablePointer(data)) > } > > Has issues with the array passed to c getting corrupted, but this doesn't: > > let data = someArrayGeneratingFunction() > > if let

Re: [swift-users] C Pointers and Memory

2016-07-29 Thread James Campbell via swift-users
So this: if let data = someArrayGeneratingFunction() { cFunction(UnsafeMutablePointer(data)) } Has issues with the array passed to c getting corrupted, but this doesn't: let data = someArrayGeneratingFunction() if let data = data { cFunction(UnsafeMutablePointer(data)) } *_

Re: [swift-users] C Pointers and Memory

2016-07-28 Thread Dmitri Gribenko via swift-users
On Thu, Jul 28, 2016 at 1:27 PM, James Campbell via swift-users wrote: > How are arrays passed to C in Linux ? I tried unwrapping an optional array > in an if statment and passing it to c. it seemed like the array was > deallocated however if I stored it in a local var in the function before the >

[swift-users] C Pointers and Memory

2016-07-28 Thread James Campbell via swift-users
How are arrays passed to C in Linux ? I tried unwrapping an optional array in an if statment and passing it to c. it seemed like the array was deallocated however if I stored it in a local var in the function before the if statment it worked perfectly fine, sureley this shouldn't work either ? *__