summaryrefslogtreecommitdiffhomepage
path: root/pkg/ilist
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/ilist')
-rw-r--r--pkg/ilist/ilist_state_autogen.go54
-rw-r--r--pkg/ilist/interface_list.go6
2 files changed, 43 insertions, 17 deletions
diff --git a/pkg/ilist/ilist_state_autogen.go b/pkg/ilist/ilist_state_autogen.go
index 4294bcb90..d175c965e 100644
--- a/pkg/ilist/ilist_state_autogen.go
+++ b/pkg/ilist/ilist_state_autogen.go
@@ -6,33 +6,59 @@ import (
"gvisor.dev/gvisor/pkg/state"
)
+func (x *List) StateTypeName() string {
+ return "pkg/ilist.List"
+}
+
+func (x *List) StateFields() []string {
+ return []string{
+ "head",
+ "tail",
+ }
+}
+
func (x *List) beforeSave() {}
-func (x *List) save(m state.Map) {
+
+func (x *List) StateSave(m state.Sink) {
x.beforeSave()
- m.Save("head", &x.head)
- m.Save("tail", &x.tail)
+ m.Save(0, &x.head)
+ m.Save(1, &x.tail)
}
func (x *List) afterLoad() {}
-func (x *List) load(m state.Map) {
- m.Load("head", &x.head)
- m.Load("tail", &x.tail)
+
+func (x *List) StateLoad(m state.Source) {
+ m.Load(0, &x.head)
+ m.Load(1, &x.tail)
+}
+
+func (x *Entry) StateTypeName() string {
+ return "pkg/ilist.Entry"
+}
+
+func (x *Entry) StateFields() []string {
+ return []string{
+ "next",
+ "prev",
+ }
}
func (x *Entry) beforeSave() {}
-func (x *Entry) save(m state.Map) {
+
+func (x *Entry) StateSave(m state.Sink) {
x.beforeSave()
- m.Save("next", &x.next)
- m.Save("prev", &x.prev)
+ m.Save(0, &x.next)
+ m.Save(1, &x.prev)
}
func (x *Entry) afterLoad() {}
-func (x *Entry) load(m state.Map) {
- m.Load("next", &x.next)
- m.Load("prev", &x.prev)
+
+func (x *Entry) StateLoad(m state.Source) {
+ m.Load(0, &x.next)
+ m.Load(1, &x.prev)
}
func init() {
- state.Register("pkg/ilist.List", (*List)(nil), state.Fns{Save: (*List).save, Load: (*List).load})
- state.Register("pkg/ilist.Entry", (*Entry)(nil), state.Fns{Save: (*Entry).save, Load: (*Entry).load})
+ state.Register((*List)(nil))
+ state.Register((*Entry)(nil))
}
diff --git a/pkg/ilist/interface_list.go b/pkg/ilist/interface_list.go
index cabf46e3f..80c655830 100644
--- a/pkg/ilist/interface_list.go
+++ b/pkg/ilist/interface_list.go
@@ -75,7 +75,7 @@ func (l *List) Back() Element {
//
// NOTE: This is an O(n) operation.
func (l *List) Len() (count int) {
- for e := l.Front(); e != nil; e = e.Next() {
+ for e := l.Front(); e != nil; e = (ElementMapper{}.linkerFor(e)).Next() {
count++
}
return count
@@ -167,13 +167,13 @@ func (l *List) Remove(e Element) {
if prev != nil {
ElementMapper{}.linkerFor(prev).SetNext(next)
- } else {
+ } else if l.head == e {
l.head = next
}
if next != nil {
ElementMapper{}.linkerFor(next).SetPrev(prev)
- } else {
+ } else if l.tail == e {
l.tail = prev
}