gotosocial/vendor/github.com/ncruces/go-sqlite3/internal/util/module.go

24 lines
502 B
Go
Raw Normal View History

package util
import (
"context"
"github.com/tetratelabs/wazero/experimental"
2024-10-25 19:09:18 +03:00
"github.com/ncruces/go-sqlite3/internal/alloc"
)
type moduleKey struct{}
type moduleState struct {
mmapState
handleState
}
func NewContext(ctx context.Context) context.Context {
state := new(moduleState)
2024-10-25 19:09:18 +03:00
ctx = experimental.WithMemoryAllocator(ctx, experimental.MemoryAllocatorFunc(alloc.NewMemory))
ctx = experimental.WithCloseNotifier(ctx, state)
ctx = context.WithValue(ctx, moduleKey{}, state)
return ctx
}