summaryrefslogtreecommitdiff
path: root/vendor/github.com/ncruces/go-sqlite3/sqlite.go
diff options
context:
space:
mode:
authorLibravatar Daenney <daenney@users.noreply.github.com>2024-09-14 16:36:25 +0200
committerLibravatar GitHub <noreply@github.com>2024-09-14 16:36:25 +0200
commit4fa0d412023ffdefc4ba63eecccd4b74e712ff7d (patch)
tree02ad2eb48c195eb52e22e6152909f45c7cae58f6 /vendor/github.com/ncruces/go-sqlite3/sqlite.go
parent[feature/frontend] Add dark version of brutalist theme (#3294) (diff)
downloadgotosocial-4fa0d412023ffdefc4ba63eecccd4b74e712ff7d.tar.xz
[chore] Update go-sqlite3 to 0.18.3 (#3295)
* [chore] Update go-sqlite3 to 0.18.3 * [chore] Fix getting the sqlite3.Conn
Diffstat (limited to 'vendor/github.com/ncruces/go-sqlite3/sqlite.go')
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/sqlite.go27
1 files changed, 14 insertions, 13 deletions
diff --git a/vendor/github.com/ncruces/go-sqlite3/sqlite.go b/vendor/github.com/ncruces/go-sqlite3/sqlite.go
index 712ad5160..b8c06d618 100644
--- a/vendor/github.com/ncruces/go-sqlite3/sqlite.go
+++ b/vendor/github.com/ncruces/go-sqlite3/sqlite.go
@@ -86,7 +86,6 @@ type sqlite struct {
mask uint32
}
stack [9]uint64
- freer uint32
}
func instantiateSQLite() (sqlt *sqlite, err error) {
@@ -102,14 +101,7 @@ func instantiateSQLite() (sqlt *sqlite, err error) {
if err != nil {
return nil, err
}
-
- global := sqlt.mod.ExportedGlobal("malloc_destructor")
- if global == nil {
- return nil, util.BadBinaryErr
- }
-
- sqlt.freer = util.ReadUint32(sqlt.mod, uint32(global.Get()))
- if sqlt.freer == 0 {
+ if sqlt.getfn("sqlite3_progress_handler_go") == nil {
return nil, util.BadBinaryErr
}
return sqlt, nil
@@ -196,14 +188,19 @@ func (sqlt *sqlite) free(ptr uint32) {
if ptr == 0 {
return
}
- sqlt.call("free", uint64(ptr))
+ sqlt.call("sqlite3_free", uint64(ptr))
}
func (sqlt *sqlite) new(size uint64) uint32 {
- if size > _MAX_ALLOCATION_SIZE {
+ ptr := uint32(sqlt.call("sqlite3_malloc64", size))
+ if ptr == 0 && size != 0 {
panic(util.OOMErr)
}
- ptr := uint32(sqlt.call("malloc", size))
+ return ptr
+}
+
+func (sqlt *sqlite) realloc(ptr uint32, size uint64) uint32 {
+ ptr = uint32(sqlt.call("sqlite3_realloc64", uint64(ptr), size))
if ptr == 0 && size != 0 {
panic(util.OOMErr)
}
@@ -214,7 +211,11 @@ func (sqlt *sqlite) newBytes(b []byte) uint32 {
if (*[0]byte)(b) == nil {
return 0
}
- ptr := sqlt.new(uint64(len(b)))
+ size := len(b)
+ if size == 0 {
+ size = 1
+ }
+ ptr := sqlt.new(uint64(size))
util.WriteBytes(sqlt.mod, ptr, b)
return ptr
}