summaryrefslogtreecommitdiff
path: root/vendor/go.etcd.io/bbolt/page.go
diff options
context:
space:
mode:
authordependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>2020-06-18 09:07:30 +0000
committerDaniel J Walsh <dwalsh@redhat.com>2020-06-18 05:55:55 -0400
commit16dbc160c5f465ca1535bc13c07293f2b0dd89e5 (patch)
tree34428e29124555bf507a433ddc9f8875a13f8c1e /vendor/go.etcd.io/bbolt/page.go
parent6472b44c3420fbba04dc3b5fe96be6576ee43e61 (diff)
downloadpodman-16dbc160c5f465ca1535bc13c07293f2b0dd89e5.tar.gz
podman-16dbc160c5f465ca1535bc13c07293f2b0dd89e5.tar.bz2
podman-16dbc160c5f465ca1535bc13c07293f2b0dd89e5.zip
Bump go.etcd.io/bbolt from 1.3.4 to 1.3.5
Bumps [go.etcd.io/bbolt](https://github.com/etcd-io/bbolt) from 1.3.4 to 1.3.5. - [Release notes](https://github.com/etcd-io/bbolt/releases) - [Commits](https://github.com/etcd-io/bbolt/compare/v1.3.4...v1.3.5) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'vendor/go.etcd.io/bbolt/page.go')
-rw-r--r--vendor/go.etcd.io/bbolt/page.go57
1 files changed, 21 insertions, 36 deletions
diff --git a/vendor/go.etcd.io/bbolt/page.go b/vendor/go.etcd.io/bbolt/page.go
index b5c169978..c9a158fb0 100644
--- a/vendor/go.etcd.io/bbolt/page.go
+++ b/vendor/go.etcd.io/bbolt/page.go
@@ -3,7 +3,6 @@ package bbolt
import (
"fmt"
"os"
- "reflect"
"sort"
"unsafe"
)
@@ -51,13 +50,13 @@ func (p *page) typ() string {
// meta returns a pointer to the metadata section of the page.
func (p *page) meta() *meta {
- return (*meta)(unsafe.Pointer(uintptr(unsafe.Pointer(p)) + unsafe.Sizeof(*p)))
+ return (*meta)(unsafeAdd(unsafe.Pointer(p), unsafe.Sizeof(*p)))
}
// leafPageElement retrieves the leaf node by index
func (p *page) leafPageElement(index uint16) *leafPageElement {
- off := uintptr(index) * unsafe.Sizeof(leafPageElement{})
- return (*leafPageElement)(unsafe.Pointer(uintptr(unsafe.Pointer(p)) + unsafe.Sizeof(*p) + off))
+ return (*leafPageElement)(unsafeIndex(unsafe.Pointer(p), unsafe.Sizeof(*p),
+ leafPageElementSize, int(index)))
}
// leafPageElements retrieves a list of leaf nodes.
@@ -65,17 +64,16 @@ func (p *page) leafPageElements() []leafPageElement {
if p.count == 0 {
return nil
}
- return *(*[]leafPageElement)(unsafe.Pointer(&reflect.SliceHeader{
- Data: uintptr(unsafe.Pointer(p)) + unsafe.Sizeof(*p),
- Len: int(p.count),
- Cap: int(p.count),
- }))
+ var elems []leafPageElement
+ data := unsafeAdd(unsafe.Pointer(p), unsafe.Sizeof(*p))
+ unsafeSlice(unsafe.Pointer(&elems), data, int(p.count))
+ return elems
}
// branchPageElement retrieves the branch node by index
func (p *page) branchPageElement(index uint16) *branchPageElement {
- off := uintptr(index) * unsafe.Sizeof(branchPageElement{})
- return (*branchPageElement)(unsafe.Pointer(uintptr(unsafe.Pointer(p)) + unsafe.Sizeof(*p) + off))
+ return (*branchPageElement)(unsafeIndex(unsafe.Pointer(p), unsafe.Sizeof(*p),
+ unsafe.Sizeof(branchPageElement{}), int(index)))
}
// branchPageElements retrieves a list of branch nodes.
@@ -83,20 +81,15 @@ func (p *page) branchPageElements() []branchPageElement {
if p.count == 0 {
return nil
}
- return *(*[]branchPageElement)(unsafe.Pointer(&reflect.SliceHeader{
- Data: uintptr(unsafe.Pointer(p)) + unsafe.Sizeof(*p),
- Len: int(p.count),
- Cap: int(p.count),
- }))
+ var elems []branchPageElement
+ data := unsafeAdd(unsafe.Pointer(p), unsafe.Sizeof(*p))
+ unsafeSlice(unsafe.Pointer(&elems), data, int(p.count))
+ return elems
}
// dump writes n bytes of the page to STDERR as hex output.
func (p *page) hexdump(n int) {
- buf := *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{
- Data: uintptr(unsafe.Pointer(p)),
- Len: n,
- Cap: n,
- }))
+ buf := unsafeByteSlice(unsafe.Pointer(p), 0, 0, n)
fmt.Fprintf(os.Stderr, "%x\n", buf)
}
@@ -115,11 +108,7 @@ type branchPageElement struct {
// key returns a byte slice of the node key.
func (n *branchPageElement) key() []byte {
- return *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{
- Data: uintptr(unsafe.Pointer(n)) + uintptr(n.pos),
- Len: int(n.ksize),
- Cap: int(n.ksize),
- }))
+ return unsafeByteSlice(unsafe.Pointer(n), 0, int(n.pos), int(n.pos)+int(n.ksize))
}
// leafPageElement represents a node on a leaf page.
@@ -132,20 +121,16 @@ type leafPageElement struct {
// key returns a byte slice of the node key.
func (n *leafPageElement) key() []byte {
- return *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{
- Data: uintptr(unsafe.Pointer(n)) + uintptr(n.pos),
- Len: int(n.ksize),
- Cap: int(n.ksize),
- }))
+ i := int(n.pos)
+ j := i + int(n.ksize)
+ return unsafeByteSlice(unsafe.Pointer(n), 0, i, j)
}
// value returns a byte slice of the node value.
func (n *leafPageElement) value() []byte {
- return *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{
- Data: uintptr(unsafe.Pointer(n)) + uintptr(n.pos) + uintptr(n.ksize),
- Len: int(n.vsize),
- Cap: int(n.vsize),
- }))
+ i := int(n.pos) + int(n.ksize)
+ j := i + int(n.vsize)
+ return unsafeByteSlice(unsafe.Pointer(n), 0, i, j)
}
// PageInfo represents human readable information about a page.