From 08bb0096c47b7db747ac1d07e857d39f5168789d Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Fri, 19 Jun 2020 13:38:28 -0400 Subject: [PATCH] rados: convert ListPools to use cutil.SplitSparseBuffer Signed-off-by: John Mulligan --- rados/conn.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/rados/conn.go b/rados/conn.go index 69a29bc..8bacb1c 100644 --- a/rados/conn.go +++ b/rados/conn.go @@ -6,9 +6,9 @@ package rados import "C" import ( - "bytes" "unsafe" + "github.com/ceph/go-ceph/internal/cutil" "github.com/ceph/go-ceph/internal/retry" ) @@ -117,14 +117,7 @@ func (c *Conn) ListPools() (names []string, err error) { continue } - tmp := bytes.SplitAfter(buf[:ret-1], []byte{0}) - for _, s := range tmp { - if len(s) > 0 { - name := C.GoString((*C.char)(unsafe.Pointer(&s[0]))) - names = append(names, name) - } - } - + names = cutil.SplitSparseBuffer(buf[:ret]) return names, nil } }