From 00f5a0137804b34cab8c4d6ab8c5551fda9e4c82 Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Thu, 18 Aug 2016 10:35:50 -0700 Subject: [PATCH] vendor: boltdb/bolt v1.3.0 for Go 1.7 --- cmd/vendor/github.com/boltdb/bolt/freelist.go | 18 ++++++++++++------ cmd/vendor/github.com/boltdb/bolt/node.go | 5 +++++ cmd/vendor/github.com/boltdb/bolt/page.go | 6 ++++++ glide.lock | 6 +++--- glide.yaml | 2 +- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/cmd/vendor/github.com/boltdb/bolt/freelist.go b/cmd/vendor/github.com/boltdb/bolt/freelist.go index 0161948fcf7..1b7ba91b2a5 100644 --- a/cmd/vendor/github.com/boltdb/bolt/freelist.go +++ b/cmd/vendor/github.com/boltdb/bolt/freelist.go @@ -166,12 +166,16 @@ func (f *freelist) read(p *page) { } // Copy the list of page ids from the freelist. - ids := ((*[maxAllocSize]pgid)(unsafe.Pointer(&p.ptr)))[idx:count] - f.ids = make([]pgid, len(ids)) - copy(f.ids, ids) + if count == 0 { + f.ids = nil + } else { + ids := ((*[maxAllocSize]pgid)(unsafe.Pointer(&p.ptr)))[idx:count] + f.ids = make([]pgid, len(ids)) + copy(f.ids, ids) - // Make sure they're sorted. - sort.Sort(pgids(f.ids)) + // Make sure they're sorted. + sort.Sort(pgids(f.ids)) + } // Rebuild the page cache. f.reindex() @@ -189,7 +193,9 @@ func (f *freelist) write(p *page) error { // The page.count can only hold up to 64k elements so if we overflow that // number then we handle it by putting the size in the first element. - if len(ids) < 0xFFFF { + if len(ids) == 0 { + p.count = uint16(len(ids)) + } else if len(ids) < 0xFFFF { p.count = uint16(len(ids)) copy(((*[maxAllocSize]pgid)(unsafe.Pointer(&p.ptr)))[:], ids) } else { diff --git a/cmd/vendor/github.com/boltdb/bolt/node.go b/cmd/vendor/github.com/boltdb/bolt/node.go index e9d64af81e3..159318b229c 100644 --- a/cmd/vendor/github.com/boltdb/bolt/node.go +++ b/cmd/vendor/github.com/boltdb/bolt/node.go @@ -201,6 +201,11 @@ func (n *node) write(p *page) { } p.count = uint16(len(n.inodes)) + // Stop here if there are no items to write. + if p.count == 0 { + return + } + // Loop over each item and write it to the page. b := (*[maxAllocSize]byte)(unsafe.Pointer(&p.ptr))[n.pageElementSize()*len(n.inodes):] for i, item := range n.inodes { diff --git a/cmd/vendor/github.com/boltdb/bolt/page.go b/cmd/vendor/github.com/boltdb/bolt/page.go index 4a555286a38..7651a6bf7d9 100644 --- a/cmd/vendor/github.com/boltdb/bolt/page.go +++ b/cmd/vendor/github.com/boltdb/bolt/page.go @@ -62,6 +62,9 @@ func (p *page) leafPageElement(index uint16) *leafPageElement { // leafPageElements retrieves a list of leaf nodes. func (p *page) leafPageElements() []leafPageElement { + if p.count == 0 { + return nil + } return ((*[0x7FFFFFF]leafPageElement)(unsafe.Pointer(&p.ptr)))[:] } @@ -72,6 +75,9 @@ func (p *page) branchPageElement(index uint16) *branchPageElement { // branchPageElements retrieves a list of branch nodes. func (p *page) branchPageElements() []branchPageElement { + if p.count == 0 { + return nil + } return ((*[0x7FFFFFF]branchPageElement)(unsafe.Pointer(&p.ptr)))[:] } diff --git a/glide.lock b/glide.lock index 30edcba382d..7f4a2d62d5c 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ -hash: 772308b285e752f35b2e87f75271501d23bbd9e72840dd1980fc6cf38a406b69 -updated: 2016-08-16T16:30:32.22550013-07:00 +hash: 0137d778163228de7f49ff31f4ec0f1f3b9c315d16a9f2e2d6d7a2ca41f968cf +updated: 2016-08-18T10:30:07.68579351-07:00 imports: - name: bitbucket.org/ww/goautoneg version: 75cd24fc2f2c2a2088577d12123ddee5f54e0675 @@ -12,7 +12,7 @@ imports: - name: github.com/bgentry/speakeasy version: 36e9cfdd690967f4f690c6edcc9ffacd006014a0 - name: github.com/boltdb/bolt - version: dfb21201d9270c1082d5fb0f07f500311ff72f18 + version: 583e8937c61f1af6513608ccc75c97b6abdf4ff9 - name: github.com/cockroachdb/cmux version: 112f0506e7743d64a6eb8fedbcff13d9979bbf92 - name: github.com/coreos/go-semver diff --git a/glide.yaml b/glide.yaml index fcf84eadfac..dfad99ef229 100644 --- a/glide.yaml +++ b/glide.yaml @@ -11,7 +11,7 @@ import: - package: github.com/bgentry/speakeasy version: 36e9cfdd690967f4f690c6edcc9ffacd006014a0 - package: github.com/boltdb/bolt - version: dfb21201d9270c1082d5fb0f07f500311ff72f18 + version: v1.3.0 - package: github.com/cockroachdb/cmux version: 112f0506e7743d64a6eb8fedbcff13d9979bbf92 - package: github.com/coreos/go-semver