handles: start slot indices with 1

Using 0 as the first slot indice leads to not being able to
differentiate between a handle to the first element or a
NULL-handle. As current code may check whether the pointer is
NULL, change the first indice to be 1 instead.
This commit is contained in:
Patrick Steinhardt 2015-04-24 09:35:58 +02:00
parent de45a4b8ed
commit 0a336e4abd
1 changed files with 1 additions and 1 deletions

View File

@ -23,7 +23,7 @@ func NewHandleList() *HandleList {
// findUnusedSlot finds the smallest-index empty space in our
// list. You must only run this function while holding a write lock.
func (v *HandleList) findUnusedSlot() uintptr {
for i := 0; i < len(v.handles); i++ {
for i := 1; i < len(v.handles); i++ {
isUsed := v.set[uintptr(i)]
if !isUsed {
return uintptr(i)