Skip to content

Commit

Permalink
STYLE: Replace memset(&pyBuffer, 0, sizeof(Py_buffer)) with {}
Browse files Browse the repository at this point in the history
`Py_buffer` is a simple struct, which can be initialized properly by an empty
initializer list, `{}`.
  • Loading branch information
N-Dekker authored and dzenanz committed Oct 3, 2024
1 parent ba6092f commit aaff35c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
6 changes: 2 additions & 4 deletions Modules/Bridge/NumPy/include/itkPyBuffer.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ PyObject *
PyBuffer<TImage>::_GetArrayViewFromImage(ImageType * image)
{
PyObject * memoryView = NULL;
Py_buffer pyBuffer;
memset(&pyBuffer, 0, sizeof(Py_buffer));
Py_buffer pyBuffer{};

Py_ssize_t len = 1;
int res = 0;
Expand Down Expand Up @@ -75,8 +74,7 @@ PyBuffer<TImage>::_GetImageViewFromArray(PyObject * arr, PyObject * shape, PyObj
PyObject * shapeseq = NULL;
PyObject * item = NULL;

Py_buffer pyBuffer;
memset(&pyBuffer, 0, sizeof(Py_buffer));
Py_buffer pyBuffer{};

SizeType size;
SizeType sizeFortran;
Expand Down
6 changes: 2 additions & 4 deletions Modules/Bridge/NumPy/include/itkPyVectorContainer.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ PyObject *
PyVectorContainer<TElementIdentifier, TElement>::_array_view_from_vector_container(VectorContainerType * vector)
{
PyObject * memoryView = NULL;
Py_buffer pyBuffer;
memset(&pyBuffer, 0, sizeof(Py_buffer));
Py_buffer pyBuffer{};

int res = 0;

Expand Down Expand Up @@ -63,8 +62,7 @@ PyVectorContainer<TElementIdentifier, TElement>::_vector_container_from_array(Py
PyObject * shapeseq = NULL;
PyObject * item = NULL;

Py_buffer pyBuffer;
memset(&pyBuffer, 0, sizeof(Py_buffer));
Py_buffer pyBuffer{};

size_t numberOfElements = 1;

Expand Down
12 changes: 4 additions & 8 deletions Modules/Bridge/NumPy/include/itkPyVnl.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ PyObject *
PyVnl<TElement>::_GetArrayViewFromVnlVector(VectorType * vector)
{
PyObject * memoryView = NULL;
Py_buffer pyBuffer;
memset(&pyBuffer, 0, sizeof(Py_buffer));
Py_buffer pyBuffer{};

int res = 0;

Expand Down Expand Up @@ -62,8 +61,7 @@ PyVnl<TElement>::_GetVnlVectorFromArray(PyObject * arr, PyObject * shape) -> con
PyObject * shapeseq = NULL;
PyObject * item = NULL;

Py_buffer pyBuffer;
memset(&pyBuffer, 0, sizeof(Py_buffer));
Py_buffer pyBuffer{};

size_t numberOfElements = 1;

Expand Down Expand Up @@ -107,8 +105,7 @@ PyObject *
PyVnl<TElement>::_GetArrayViewFromVnlMatrix(MatrixType * matrix)
{
PyObject * memoryView = NULL;
Py_buffer pyBuffer;
memset(&pyBuffer, 0, sizeof(Py_buffer));
Py_buffer pyBuffer{};

int res = 0;

Expand Down Expand Up @@ -141,8 +138,7 @@ PyVnl<TElement>::_GetVnlMatrixFromArray(PyObject * arr, PyObject * shape) -> con
PyObject * shapeseq = NULL;
PyObject * item = NULL;

Py_buffer pyBuffer;
memset(&pyBuffer, 0, sizeof(Py_buffer));
Py_buffer pyBuffer{};

size_t numberOfElements = 1;

Expand Down

0 comments on commit aaff35c

Please sign in to comment.