rbd: convert NamespaceList for nautilus to use cutil.SplitSparseBuffer

Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
John Mulligan 2020-06-19 13:38:28 -04:00 committed by John Mulligan
parent 4d2d6493af
commit 2a62588181
1 changed files with 3 additions and 8 deletions

View File

@ -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
}