Skip to content

Commit b34a908

Browse files
committed
Ensure buffer is C_CONTIGUOUS
1 parent bbd26e8 commit b34a908

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/isal/isal_zlib.pyx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ from .crc cimport crc32_gzip_refl
7070
from .igzip_lib cimport *
7171
from libc.stdint cimport UINT64_MAX, UINT32_MAX
7272
from cpython.mem cimport PyMem_Malloc, PyMem_Realloc, PyMem_Free
73-
from cpython.buffer cimport PyBUF_SIMPLE, PyObject_GetBuffer, PyBuffer_Release
73+
from cpython.buffer cimport PyBUF_C_CONTIGUOUS, PyObject_GetBuffer, PyBuffer_Release
7474
from cpython.bytes cimport PyBytes_FromStringAndSize
7575
from cpython.long cimport PyLong_AsUnsignedLongMask
7676

@@ -138,7 +138,7 @@ def adler32(data, value = 1):
138138
cdef Py_buffer buffer_data
139139
cdef Py_buffer* buffer = &buffer_data
140140
# Cython makes sure error is handled when acquiring buffer fails.
141-
PyObject_GetBuffer(data, buffer, PyBUF_SIMPLE)
141+
PyObject_GetBuffer(data, buffer, PyBUF_C_CONTIGUOUS)
142142
try:
143143
if buffer.len > UINT64_MAX:
144144
raise ValueError("Data too big for adler32")
@@ -158,7 +158,7 @@ def crc32(data, value = 0):
158158
cdef Py_buffer buffer_data
159159
cdef Py_buffer* buffer = &buffer_data
160160
# Cython makes sure error is handled when acquiring buffer fails.
161-
PyObject_GetBuffer(data, buffer, PyBUF_SIMPLE)
161+
PyObject_GetBuffer(data, buffer, PyBUF_C_CONTIGUOUS)
162162
try:
163163
if buffer.len > UINT64_MAX:
164164
raise ValueError("Data too big for adler32")
@@ -262,7 +262,7 @@ def compress(data,
262262
cdef Py_buffer buffer_data
263263
cdef Py_buffer* buffer = &buffer_data
264264
# Cython makes sure error is handled when acquiring buffer fails.
265-
PyObject_GetBuffer(data, buffer, PyBUF_SIMPLE)
265+
PyObject_GetBuffer(data, buffer, PyBUF_C_CONTIGUOUS)
266266
cdef Py_ssize_t ibuflen = buffer.len
267267
stream.next_in = <unsigned char*>buffer.buf
268268

@@ -328,7 +328,7 @@ def decompress(data,
328328
cdef Py_buffer buffer_data
329329
cdef Py_buffer* buffer = &buffer_data
330330
# Cython makes sure error is handled when acquiring buffer fails.
331-
PyObject_GetBuffer(data, buffer, PyBUF_SIMPLE)
331+
PyObject_GetBuffer(data, buffer, PyBUF_C_CONTIGUOUS)
332332
cdef Py_ssize_t ibuflen = buffer.len
333333
stream.next_in = <unsigned char*>buffer.buf
334334

@@ -464,7 +464,7 @@ cdef class Compress:
464464
cdef Py_buffer buffer_data
465465
cdef Py_buffer* buffer = &buffer_data
466466
# Cython makes sure error is handled when acquiring buffer fails.
467-
PyObject_GetBuffer(data, buffer, PyBUF_SIMPLE)
467+
PyObject_GetBuffer(data, buffer, PyBUF_C_CONTIGUOUS)
468468
cdef Py_ssize_t ibuflen = buffer.len
469469
self.stream.next_in = <unsigned char*>buffer.buf
470470

@@ -631,7 +631,7 @@ cdef class Decompress:
631631
cdef Py_buffer buffer_data
632632
cdef Py_buffer* buffer = &buffer_data
633633
# Cython makes sure error is handled when acquiring buffer fails.
634-
PyObject_GetBuffer(data, buffer, PyBUF_SIMPLE)
634+
PyObject_GetBuffer(data, buffer, PyBUF_C_CONTIGUOUS)
635635
cdef Py_ssize_t ibuflen = buffer.len
636636
self.stream.next_in = <unsigned char*>buffer.buf
637637

@@ -681,7 +681,7 @@ cdef class Decompress:
681681
cdef Py_buffer buffer_data
682682
cdef Py_buffer* buffer = &buffer_data
683683
# Cython makes sure error is handled when acquiring buffer fails.
684-
PyObject_GetBuffer(self.unconsumed_tail, buffer, PyBUF_SIMPLE)
684+
PyObject_GetBuffer(self.unconsumed_tail, buffer, PyBUF_C_CONTIGUOUS)
685685
cdef Py_ssize_t ibuflen = buffer.len
686686
self.stream.next_in = <unsigned char*>buffer.buf
687687

0 commit comments

Comments
 (0)