1package util
2
3import (
4 "context"
5
6 "github.com/tetratelabs/wazero/experimental"
7
8 "github.com/ncruces/go-sqlite3/internal/alloc"
9)
10
11type ConnKey struct{}
12
13type moduleKey struct{}
14type moduleState struct {
15 mmapState
16 handleState
17}
18
19func NewContext(ctx context.Context) context.Context {
20 state := new(moduleState)
21 ctx = experimental.WithMemoryAllocator(ctx, experimental.MemoryAllocatorFunc(alloc.NewMemory))
22 ctx = experimental.WithCloseNotifier(ctx, state)
23 ctx = context.WithValue(ctx, moduleKey{}, state)
24 return ctx
25}