Source File
handle.go
Belonging Package
github.com/ncruces/go-sqlite3/internal/util
package utilimport ()type handleState struct {handles []anyholes int}func ( *handleState) ( context.Context, uint32) {for , := range .handles {if , := .(io.Closer); {.Close()}}.handles = nil.holes = 0}func ( context.Context, Ptr_t) any {if == 0 {return nil}:= .Value(moduleKey{}).(*moduleState)return .handles[^]}func ( context.Context, Ptr_t) error {if == 0 {return nil}:= .Value(moduleKey{}).(*moduleState):= .handles[^].handles[^] = nilif := Ptr_t(len(.handles)); == ^ {.handles = .handles[:-1]} else {.holes++}if , := .(io.Closer); {return .Close()}return nil}func ( context.Context, any) Ptr_t {if == nil {panic(NilErr)}:= .Value(moduleKey{}).(*moduleState)// Find an empty slot.if .holes > cap(.handles)-len(.handles) {for , := range .handles {if == nil {.holes--.handles[] =return ^Ptr_t()}}}// Add a new slot..handles = append(.handles, )return -Ptr_t(len(.handles))}
![]() |
The pages are generated with Golds v0.8.2. (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. |