e.next = nil // avoid memory leaks e.prev = nil // avoid memory leaks 内存泄漏

/Go/src/container/list/list.go:10

 

// remove removes e from its list, decrements l.len, and returns e.
func (l *List) remove(e *Element) *Element {
e.prev.next = e.next
e.next.prev = e.prev
e.next = nil // avoid memory leaks
e.prev = nil // avoid memory leaks
e.list = nil
l.len--
return e
}

 

posted @ 2020-11-18 16:35  papering  阅读(116)  评论(0编辑  收藏  举报