malloc replaced with UnsafePointer.alloc

free replaced with UnsafePointer($0).destroy()