2024-09-30 10:46:23 +00:00
|
|
|
//go:build !unix || !(amd64 || arm64 || riscv64 || ppc64le) || sqlite3_noshm || sqlite3_nosys
|
2024-05-27 15:46:15 +00:00
|
|
|
|
|
|
|
package util
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2024-06-07 13:06:43 +00:00
|
|
|
"github.com/ncruces/go-sqlite3/internal/alloc"
|
2024-05-27 15:46:15 +00:00
|
|
|
"github.com/tetratelabs/wazero/experimental"
|
|
|
|
)
|
|
|
|
|
|
|
|
type mmapState struct{}
|
|
|
|
|
|
|
|
func withAllocator(ctx context.Context) context.Context {
|
|
|
|
return experimental.WithMemoryAllocator(ctx,
|
|
|
|
experimental.MemoryAllocatorFunc(func(cap, max uint64) experimental.LinearMemory {
|
|
|
|
if cap == max {
|
2024-06-07 13:06:43 +00:00
|
|
|
return alloc.Virtual(cap, max)
|
2024-05-27 15:46:15 +00:00
|
|
|
}
|
2024-06-07 13:06:43 +00:00
|
|
|
return alloc.Slice(cap, max)
|
2024-05-27 15:46:15 +00:00
|
|
|
}))
|
|
|
|
}
|