A mysterious bug has got me thinking about using UnsafePointer<CChar> with 
NSData (Swift 2).

Is this safe:

let data:NSData = …
let dataStart = UnsafePointer<CChar>(data:NSDAta.bytes)

myProcessdata1(dataStart,data.length)

… (no more references to data)

And this:

let data:NSData = …
myProcessdata2(data)

… (no more references to data)

func myProcessdata2( data:NSData )
{
let dataStart = UnsafePointer<CChar>(data:NSData.bytes)
myProcessdata1(dataStart,data.length)
}

In the latter case I would hope that data remains alive until the function 
myProcessdata2 returns. But does it?

TIA,

Jan E.


_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to