naman's changes.
diff --git a/z/allocator.go b/z/allocator.go
index afd574e..d67c08b 100644
--- a/z/allocator.go
+++ b/z/allocator.go
@@ -76,7 +76,8 @@
buffers: make([][]byte, 32),
}
l2 := uint64(log2(sz))
- a.buffers[0] = Calloc(1 << (l2 + 1))
+ // a.buffers[0] = Calloc(1 << (l2 + 1))
+ a.buffers[0] = make([]byte, 1<<(l2+1))
allocsMu.Lock()
allocs[ref] = a
@@ -85,6 +86,15 @@
}
func (a *Allocator) Reset() {
+ if a == nil {
+ return
+ }
+ for _, b := range a.buffers {
+ if len(b) == 0 {
+ break
+ }
+ ZeroOut(b, 0, len(b))
+ }
atomic.StoreUint64(&a.compIdx, 0)
}
@@ -177,7 +187,7 @@
if alloc < max {
continue
}
- Free(b)
+ // Free(b)
a.buffers[i] = nil
}
}
@@ -194,7 +204,7 @@
break
}
alloc += len(b)
- Free(b)
+ // Free(b)
}
allocsMu.Lock()
@@ -261,7 +271,8 @@
pageSize = maxAlloc
}
- buf := Calloc(pageSize)
+ // buf := Calloc(pageSize)
+ buf := make([]byte, pageSize)
assert(len(a.buffers[bufIdx]) == 0)
a.buffers[bufIdx] = buf
}
@@ -326,6 +337,7 @@
default:
return NewAllocator(sz)
}
+ // return NewAllocator(sz)
}
func (p *AllocatorPool) Return(a *Allocator) {
if a == nil {