diff options
| author | Patrick Steinhardt <[email protected]> | 2015-04-24 09:35:58 +0200 |
|---|---|---|
| committer | Patrick Steinhardt <[email protected]> | 2015-05-22 09:02:24 +0200 |
| commit | 0a336e4abdd7c949c9dd38037165e6a16c7d7ebf (patch) | |
| tree | fb47d9f3845a936fbebb883bfd7325d19e9eda7d | |
| parent | de45a4b8ed991cd46e64a1836e25dd9b182c821f (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.
| -rw-r--r-- | handles.go | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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) |
