Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Unified Diff: tools/slab/slab.go

Issue 1409173004: Remove usage of unsafe from gkvlite (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gkvlite.git@master
Patch Set: get locks out of other lock Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « store_test.go ('k') | tools/slab/slab_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/slab/slab.go
diff --git a/tools/slab/slab.go b/tools/slab/slab.go
index 594b0cce4d76a7ccaa4393a9026445359fbcb1e8..b2273f31ef5b17a3bfe79e3748b3e55bdc0c1ba7 100644
--- a/tools/slab/slab.go
+++ b/tools/slab/slab.go
@@ -14,7 +14,6 @@ import (
"os"
"sort"
"testing"
- "unsafe"
"github.com/luci/gkvlite"
"github.com/steveyen/go-slab"
@@ -167,11 +166,11 @@ func setupStoreArena(t *testing.T, maxBufSize int) (
n.next = nil
} else {
n = &ItemNode{}
- n.item.Transient = unsafe.Pointer(n)
+ n.item.Transient = n
}
if n.refs != 0 ||
n.item.Key != nil || n.item.Val != nil || n.item.Priority != 0 ||
- n.item.Transient != unsafe.Pointer(n) {
+ n.item.Transient != n {
panic("unexpected ItemNode refs or item fields")
}
n.refs = 1
@@ -180,11 +179,11 @@ func setupStoreArena(t *testing.T, maxBufSize int) (
return &n.item
}
itemAddRef := func(c *gkvlite.Collection, i *gkvlite.Item) {
- n := (*ItemNode)(i.Transient)
+ n := i.Transient.(*ItemNode)
n.refs++
}
itemDecRef := func(c *gkvlite.Collection, i *gkvlite.Item) {
- n := (*ItemNode)(i.Transient)
+ n := i.Transient.(*ItemNode)
n.refs--
if n.refs == 0 {
if i.Key == nil {
« no previous file with comments | « store_test.go ('k') | tools/slab/slab_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698