First set of code review patches

This commit is contained in:
Mathias Hall-Andersen
2017-08-04 16:15:53 +02:00
parent 22c83f4b8d
commit 8c34c4cbb3
15 changed files with 315 additions and 182 deletions
+2 -8
View File
@@ -3,6 +3,7 @@ package main
import (
"crypto/rand"
"sync"
"unsafe"
)
/* Index=0 is reserved for unset indecies
@@ -23,14 +24,7 @@ type IndexTable struct {
func randUint32() (uint32, error) {
var buff [4]byte
_, err := rand.Read(buff[:])
id := uint32(buff[0])
id <<= 8
id |= uint32(buff[1])
id <<= 8
id |= uint32(buff[2])
id <<= 8
id |= uint32(buff[3])
return id, err
return *((*uint32)(unsafe.Pointer(&buff))), err
}
func (table *IndexTable) Init() {