Skip to content

Commit

Permalink
Merge pull request #267 from ianlancetaylor/go16
Browse files Browse the repository at this point in the history
bind: pass &v[0] in direct call to C
  • Loading branch information
mattn committed Feb 1, 2016
2 parents 57d9aeb + b76c610 commit c5aee96
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sqlite3.go
Original file line number Diff line number Diff line change
Expand Up @@ -815,11 +815,11 @@ func (s *SQLiteStmt) bind(args []driver.Value) error {
case float64:
rv = C.sqlite3_bind_double(s.s, n, C.double(v))
case []byte:
var p *byte
if len(v) > 0 {
p = &v[0]
if len(v) == 0 {
rv = C._sqlite3_bind_blob(s.s, n, nil, 0)
} else {
rv = C._sqlite3_bind_blob(s.s, n, unsafe.Pointer(&v[0]), C.int(len(v)))
}
rv = C._sqlite3_bind_blob(s.s, n, unsafe.Pointer(p), C.int(len(v)))
case time.Time:
b := []byte(v.Format(SQLiteTimestampFormats[0]))
rv = C._sqlite3_bind_text(s.s, n, (*C.char)(unsafe.Pointer(&b[0])), C.int(len(b)))
Expand Down

0 comments on commit c5aee96

Please sign in to comment.