From 2a62588181671032296ff0b8899b22b5fc372434 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Fri, 19 Jun 2020 13:38:28 -0400 Subject: [PATCH] rbd: convert NamespaceList for nautilus to use cutil.SplitSparseBuffer Signed-off-by: John Mulligan --- rbd/namespace_nautilus.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/rbd/namespace_nautilus.go b/rbd/namespace_nautilus.go index fb78a9a..5b0e201 100644 --- a/rbd/namespace_nautilus.go +++ b/rbd/namespace_nautilus.go @@ -13,9 +13,9 @@ package rbd import "C" import ( - "bytes" "unsafe" + "github.com/ceph/go-ceph/internal/cutil" "github.com/ceph/go-ceph/internal/retry" "github.com/ceph/go-ceph/rados" ) @@ -100,12 +100,7 @@ func NamespaceList(ioctx *rados.IOContext) (names []string, err error) { if err != nil { return nil, err } - tmpList := bytes.Split(buf[:cSize-1], []byte{0}) - for _, s := range tmpList { - if len(s) > 0 { - name := C.GoString((*C.char)(unsafe.Pointer(&s[0]))) - names = append(names, name) - } - } + + names = cutil.SplitSparseBuffer(buf[:cSize]) return names, nil }