Skip to content

Commit f9af3a9

Browse files
author
Kyle Jessup
committed
pr tweak
1 parent c038ecc commit f9af3a9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Sources/PerfectMySQL/MySQLStmt.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,11 @@ public final class MySQLStmt {
753753
}
754754

755755
private func bind() {
756+
// empty buffer shared by .bytes, .string, .date, .null types
756757
let scratch = UnsafeMutableRawPointer(UnsafeMutablePointer<Int8>.allocate(capacity: 0))
758+
defer {
759+
scratch.deallocate()
760+
}
757761
for i in 0..<numFields {
758762
guard let field = mysql_fetch_field_direct(meta, UInt32(i)) else {
759763
continue
@@ -808,7 +812,6 @@ public final class MySQLStmt {
808812
}
809813
binds.advanced(by: i).initialize(to: bind)
810814
}
811-
free(scratch)
812815
mysql_stmt_bind_result(stmt.ptr, binds)
813816
}
814817

0 commit comments

Comments
 (0)