Skip to content

Commit

Permalink
Replace reflect.SliceHeader with unsafe.Slice
Browse files Browse the repository at this point in the history
  • Loading branch information
shane-ns1 committed Oct 25, 2023
1 parent ae42c40 commit dc20385
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
9 changes: 2 additions & 7 deletions cmd/lmdb_stat/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"io"
"log"
"os"
"reflect"
"strings"
"unsafe"

Expand Down Expand Up @@ -237,12 +236,8 @@ func doPrintFree(env *lmdb.Env, opt *Options) error {
numpages += ipages
if opt.PrintFreeSummary || opt.PrintFreeFull {
bad := ""
hdr := reflect.SliceHeader{
Data: uintptr(unsafe.Pointer(&data[0])),
Len: int(ipages) + 1,
Cap: int(ipages) + 1,
}
pages := *(*[]C.size_t)(unsafe.Pointer(&hdr))
datap := (*C.size_t)(unsafe.Pointer(&data[0]))
pages := unsafe.Slice(datap, ipages+1)
pages = pages[1:]
var span C.size_t
prev := C.size_t(1)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/PowerDNS/lmdb-go

go 1.15
go 1.17

require golang.org/x/net v0.0.0-20210415231046-e915ea6b2b7d

0 comments on commit dc20385

Please sign in to comment.