Skip to content

Commit fb66ad1

Browse files
committed
Add field to generation
In Go, two zero-sized structs can be placed in the same memory address.
1 parent 88437c0 commit fb66ad1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

trie/ctrie/ctrie.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ type Ctrie struct {
6363
}
6464

6565
// generation demarcates Ctrie snapshots. We use a heap-allocated reference
66-
// instead of an integer to avoid integer overflows.
67-
type generation struct{}
66+
// instead of an integer to avoid integer overflows. Struct must have a field
67+
// on it since two distinct zero-size variables may have the same address in
68+
// memory.
69+
type generation struct{ _ int }
6870

6971
// iNode is an indirection node. I-nodes remain present in the Ctrie even as
7072
// nodes above and below change. Thread-safety is achieved in part by

0 commit comments

Comments
 (0)