You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think there are leaks in these 2 methods. The 2 places "UnsafeMutablePointer*.allocate" is called there is no dealloc (or a defer dealloc). Under instruments in Xcode these show as leaks of 16 bytes for each call made to these methods.
func _call(_ function: IM3Function, args: [String]) throws {
try args.withCStrings { cStrings throws -> Void in
var mutableCStrings = cStrings
let size = UnsafeMutablePointer<Int>.allocate(capacity: 1) <-- here
let r = wasm3_CallWithArgs(
function,
UInt32(args.count),
&mutableCStrings,
size,
nil
)
if let result = r {
throw WasmInterpreterError.onCallFunction(String(cString: result))
} else if size.pointee != 0 {
throw WasmInterpreterError.invalidFunctionReturnType
} else {
return ()
}
}
}
func _call<T: WasmTypeProtocol>(_ function: IM3Function, args: [String]) throws -> T {
try args.withCStrings { cStrings throws -> T in
var mutableCStrings = cStrings
let size = UnsafeMutablePointer<Int>.allocate(capacity: 1) <-- here
let output = UnsafeMutablePointer<T>.allocate(capacity: 1) <-- not sure since we return pointee, but may be ok.
let r = wasm3_CallWithArgs(
function,
UInt32(args.count),
&mutableCStrings,
size,
output
)
if let result = r {
throw WasmInterpreterError.onCallFunction(String(cString: result))
} else if MemoryLayout<T>.size != size.pointee {
throw WasmInterpreterError.invalidFunctionReturnType
} else {
return output.pointee
}
}
}
The text was updated successfully, but these errors were encountered:
I think there are leaks in these 2 methods. The 2 places "UnsafeMutablePointer*.allocate" is called there is no dealloc (or a defer dealloc). Under instruments in Xcode these show as leaks of 16 bytes for each call made to these methods.
The text was updated successfully, but these errors were encountered: