summaryrefslogtreecommitdiff
path: root/handles.go
diff options
context:
space:
mode:
authorPatrick Steinhardt <[email protected]>2015-04-24 09:35:58 +0200
committerPatrick Steinhardt <[email protected]>2015-05-22 09:02:24 +0200
commit0a336e4abdd7c949c9dd38037165e6a16c7d7ebf (patch)
treefb47d9f3845a936fbebb883bfd7325d19e9eda7d /handles.go
parentde45a4b8ed991cd46e64a1836e25dd9b182c821f (diff)
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.
Diffstat (limited to 'handles.go')
-rw-r--r--handles.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/handles.go b/handles.go
index a862746..d173785 100644
--- a/handles.go
+++ b/handles.go
@@ -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)