Source File
wrap.go
Belonging Package
github.com/ncruces/go-sqlite3
// Package sqlite3 wraps the C SQLite API.package sqlite3import (_sqlite3_wasm)type configKey struct{}// WithMaxMemory returns a derived context that configures// each SQLite connection not to use more than max amount of memory.func ( context.Context, int64) context.Context {if < 0 || > 65536*65536 {panic(errutil.OOMErr)}return context.WithValue(, configKey{}, /65536)}//go:linkname createWrapperfunc createWrapper( context.Context) (*sqlite3_wrap.Wrapper, error) {:= &sqlite3_wrap.Memory{Max: 4096} // 256MBif bits.UintSize < 64 {.Max = 512 // 32MB}if , := .Value(configKey{}).(int64); {.Max = max(, int64(len(.Buf))/65536)}.Grow(5 /*320KB*/, .Max):= env{&sqlite3_wrap.Wrapper{Memory: }}.Module = sqlite3_wasm.New().X_initialize()return .Wrapper, nil}//go:linkname connBadfunc connBad( *Conn) bool {return .wrp.Module == nil || .stack != *.wrp.X__stack_pointer()}type env struct{ *sqlite3_wrap.Wrapper }func ( env) ( int32) int32 {if vfs.Find(.ReadString(ptr_t(), _MAX_NAME)) != nil {return 1}return 0}
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |