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:
parent
de45a4b8ed
commit
0a336e4abd
|
@ -23,7 +23,7 @@ func NewHandleList() *HandleList {
|
||||||
// findUnusedSlot finds the smallest-index empty space in our
|
// findUnusedSlot finds the smallest-index empty space in our
|
||||||
// list. You must only run this function while holding a write lock.
|
// list. You must only run this function while holding a write lock.
|
||||||
func (v *HandleList) findUnusedSlot() uintptr {
|
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)]
|
isUsed := v.set[uintptr(i)]
|
||||||
if !isUsed {
|
if !isUsed {
|
||||||
return uintptr(i)
|
return uintptr(i)
|
||||||
|
|
Loading…
Reference in New Issue