From 2d33c55c6bfa8903c3318e75cd03af51088c179a Mon Sep 17 00:00:00 2001 From: Livio Soares Date: Fri, 25 Mar 2016 00:08:28 -0400 Subject: [PATCH] rados: Fix iterator memory allocation; allocating a c_entry is not necessary and performed directly by the library. --- rados/ioctx.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/rados/ioctx.go b/rados/ioctx.go index 82f8d79..585f1a7 100644 --- a/rados/ioctx.go +++ b/rados/ioctx.go @@ -578,14 +578,12 @@ func (iter *Iter) Seek(token IterToken) { // return iter.Err() // func (iter *Iter) Next() bool { - centry := (*C.char)(C.calloc(1, 1024)) - defer C.free(unsafe.Pointer(centry)) - - if cerr := C.rados_objects_list_next(iter.ctx, ¢ry, nil); cerr < 0 { + var c_entry *C.char + if cerr := C.rados_objects_list_next(iter.ctx, &c_entry, nil); cerr < 0 { iter.err = GetRadosError(cerr) return false } - iter.entry = C.GoString(centry) + iter.entry = C.GoString(c_entry) return true }