From da5d4c813ffdd391da54dcf5022763616bab4b21 Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Thu, 4 Feb 2021 20:32:40 +0000 Subject: [PATCH] pybind: make the binding aware about rados_nobjects_list_next2(). Signed-off-by: Radoslaw Zarzynski --- src/pybind/rados/c_rados.pxd | 7 +++++++ src/pybind/rados/mock_rados.pxi | 3 +++ src/pybind/rados/rados.pyx | 12 ++++++++---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/pybind/rados/c_rados.pxd b/src/pybind/rados/c_rados.pxd index 97ee5d0b906..1f171dd4741 100644 --- a/src/pybind/rados/c_rados.pxd +++ b/src/pybind/rados/c_rados.pxd @@ -191,6 +191,13 @@ cdef extern from "rados/librados.h" nogil: int rados_nobjects_list_open(rados_ioctx_t io, rados_list_ctx_t *ctx) int rados_nobjects_list_next(rados_list_ctx_t ctx, const char **entry, const char **key, const char **nspace) + int rados_nobjects_list_next2(rados_list_ctx_t ctx, + const char **entry, + const char **key, + const char **nspace, + size_t *entry_size, + size_t *key_size, + size_t *nspace) void rados_nobjects_list_close(rados_list_ctx_t ctx) int rados_ioctx_pool_requires_alignment2(rados_ioctx_t io, int * requires) diff --git a/src/pybind/rados/mock_rados.pxi b/src/pybind/rados/mock_rados.pxi index 38053af8020..94d6b378dc7 100644 --- a/src/pybind/rados/mock_rados.pxi +++ b/src/pybind/rados/mock_rados.pxi @@ -267,6 +267,9 @@ cdef nogil: pass int rados_nobjects_list_next(rados_list_ctx_t ctx, const char **entry, const char **key, const char **nspace): pass + int rados_nobjects_list_next2(rados_list_ctx_t ctx, const char **entry, const char **key, const char **nspace, + size_t *entry_size, size_t *key_size, size_t *nspace_size): + pass void rados_nobjects_list_close(rados_list_ctx_t ctx): pass diff --git a/src/pybind/rados/rados.pyx b/src/pybind/rados/rados.pyx index 0c300ca4047..36ecd9fe3d6 100644 --- a/src/pybind/rados/rados.pyx +++ b/src/pybind/rados/rados.pyx @@ -1420,16 +1420,20 @@ cdef class ObjectIterator(object): const char *key_ = NULL const char *locator_ = NULL const char *nspace_ = NULL + size_t key_size_ = 0 + size_t locator_size_ = 0 + size_t nspace_size_ = 0 with nogil: - ret = rados_nobjects_list_next(self.ctx, &key_, &locator_, &nspace_) + ret = rados_nobjects_list_next2(self.ctx, &key_, &locator_, &nspace_, + &key_size_, &locator_size_, &nspace_size_) if ret < 0: raise StopIteration() - key = decode_cstr(key_) - locator = decode_cstr(locator_) if locator_ != NULL else None - nspace = decode_cstr(nspace_) if nspace_ != NULL else None + key = decode_cstr(key_[:key_size_]) + locator = decode_cstr(locator_[:locator_size_]) if locator_ != NULL else None + nspace = decode_cstr(nspace_[:nspace_size_]) if nspace_ != NULL else None return Object(self.ioctx, key, locator, nspace) def __dealloc__(self):