bNode runtime.ListNodeManual
}
+// ListHeadManual is intended to be used with objects where the lifetime of the
+// object is managed explicitly, so it is OK to store as uintptr.
+//
+// This means that our test values must outlive the test, and must not live on
+// the stack (which may move).
+var allListedValManual []*listedValManual
+
func newListedValManual(v int) *listedValManual {
- return &listedValManual{
+ lv := &listedValManual{
val: v,
}
+ allListedValManual = append(allListedValManual, lv)
+ return lv
}
func TestListManualPush(t *testing.T) {
headA := newListHeadNIH()
headA.Init(unsafe.Offsetof(listedValNIH{}.aNode))
- one := newListedVal(1)
+ one := newListedValNIH(1)
headA.Push(unsafe.Pointer(one))
- two := newListedVal(2)
+ two := newListedValNIH(2)
headA.Push(unsafe.Pointer(two))
- three := newListedVal(3)
+ three := newListedValNIH(3)
headA.Push(unsafe.Pointer(three))
p := headA.Pop()
headA := newListHeadNIH()
headA.Init(unsafe.Offsetof(listedValNIH{}.aNode))
- one := newListedVal(1)
+ one := newListedValNIH(1)
headA.Push(unsafe.Pointer(one))
- two := newListedVal(2)
+ two := newListedValNIH(2)
headA.Push(unsafe.Pointer(two))
- three := newListedVal(3)
+ three := newListedValNIH(3)
headA.Push(unsafe.Pointer(three))
headA.Remove(unsafe.Pointer(three))
headA := newListHeadNIH()
headA.Init(unsafe.Offsetof(listedValNIH{}.aNode))
- one := newListedVal(1)
+ one := newListedValNIH(1)
headA.Push(unsafe.Pointer(one))
- two := newListedVal(2)
+ two := newListedValNIH(2)
headA.Push(unsafe.Pointer(two))
- three := newListedVal(3)
+ three := newListedValNIH(3)
headA.Push(unsafe.Pointer(three))
headA.Remove(unsafe.Pointer(two))
headA := newListHeadNIH()
headA.Init(unsafe.Offsetof(listedValNIH{}.aNode))
- one := newListedVal(1)
+ one := newListedValNIH(1)
headA.Push(unsafe.Pointer(one))
- two := newListedVal(2)
+ two := newListedValNIH(2)
headA.Push(unsafe.Pointer(two))
- three := newListedVal(3)
+ three := newListedValNIH(3)
headA.Push(unsafe.Pointer(three))
headA.Remove(unsafe.Pointer(one))
headA := newListHeadNIH()
headA.Init(unsafe.Offsetof(listedValNIH{}.aNode))
- one := newListedVal(1)
+ one := newListedValNIH(1)
headA.Push(unsafe.Pointer(one))
- two := newListedVal(2)
+ two := newListedValNIH(2)
headA.Push(unsafe.Pointer(two))
- three := newListedVal(3)
+ three := newListedValNIH(3)
headA.Push(unsafe.Pointer(three))
headA.Remove(unsafe.Pointer(one))