Monday, 15 February 2010

go - Is this a safe way to empty a list in Golang? -



go - Is this a safe way to empty a list in Golang? -

an traditional way:

// clear elements iterating var next *element e := l.front(); e != nil; e = next { next = e.next() l.remove(e) }

how using:

l.init()

is safe way not causing memory leak?

from http://golang.org/pkg/container/list/#list.init

init initializes or clears list l.

a side note, piece improve usage scenarios, check slice tricks.

list go

No comments:

Post a Comment