pointers - Call native method from Swift that has uint8_t ** as output parameter -
i have c method interface
size_t foo(uint8_t ** output) this gets imported swift as
func foo(_ output: unsafemutablepointer<unsafemutablepointer<uint8>>) -> int how can call method swift?
assuming foo() allocates uint8_t array, puts address memory location pointed output, , returns size of allocated array, can use swift this
var output : unsafemutablepointer<uint8> = nil let size = foo(&output) in 0 ..< size { println(output[i]) } you have decide responsible releasing allocated memory. if foo() functions allocates using malloc() can release swift with
free(output)
Comments
Post a Comment