Skip to content

Commit 04ac8e7

Browse files
committed
Use correct int types
1 parent 0d14c11 commit 04ac8e7

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

src/isal/crc.pxd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
# cython: language_level=3
2222

2323
cdef extern from "<isa-l/crc.h>":
24-
cdef unsigned long crc32_gzip_refl(
25-
unsigned long init_crc, #!< initial CRC value, 32 bits
24+
cdef unsigned int crc32_gzip_refl(
25+
unsigned int init_crc, #!< initial CRC value, 32 bits
2626
const unsigned char *buf, #!< buffer to calculate CRC on
2727
unsigned long long len #!< buffer length in bytes (64-bit data)
2828
)

src/isal/igzip_lib.pxd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,6 @@ cdef extern from "<isa-l/igzip_lib.h>":
449449
# *
450450
# * @returns 32-bit Adler-32 checksum
451451
# */
452-
unsigned long isal_adler32(unsigned int init,
452+
unsigned int isal_adler32(unsigned int init,
453453
const unsigned char *buf,
454454
unsigned long long len)

src/isal/isal_zlib.pyx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ if ISAL_DEF_MAX_HIST_BITS > zlib.MAX_WBITS:
8383
"Please contact the developers.")
8484

8585

86-
cpdef adler32(data, unsigned long value = 1):
86+
cpdef adler32(data, unsigned int value = 1):
8787
cdef Py_buffer buffer_data
8888
cdef Py_buffer* buffer = &buffer_data
8989
if PyObject_GetBuffer(data, buffer, PyBUF_READ & PyBUF_C_CONTIGUOUS) != 0:
@@ -95,7 +95,7 @@ cpdef adler32(data, unsigned long value = 1):
9595
finally:
9696
PyBuffer_Release(buffer)
9797

98-
cpdef crc32(data, unsigned long value = 0):
98+
cpdef crc32(data, unsigned int value = 0):
9999
cdef Py_buffer buffer_data
100100
cdef Py_buffer* buffer = &buffer_data
101101
if PyObject_GetBuffer(data, buffer, PyBUF_READ & PyBUF_C_CONTIGUOUS) != 0:
@@ -117,14 +117,14 @@ ctypedef fused stream_or_state:
117117
isal_zstream
118118
inflate_state
119119

120-
cdef unsigned long unsigned_long_min(unsigned long a, unsigned long b):
120+
cdef unsigned int unsigned_int_min(unsigned int a, unsigned int b):
121121
if a <= b:
122122
return a
123123
else:
124124
return b
125125

126126
cdef void arrange_input_buffer(stream_or_state *stream, Py_ssize_t *remains):
127-
stream.avail_in = unsigned_long_min(<unsigned long>remains[0], UINT32_MAX)
127+
stream.avail_in = unsigned_int_min(<unsigned int>remains[0], UINT32_MAX)
128128
remains[0] -= stream.avail_in
129129

130130
def compress(data,
@@ -135,7 +135,7 @@ def compress(data,
135135

136136
# Initialise stream
137137
cdef isal_zstream stream
138-
cdef unsigned long level_buf_size = zlib_mem_level_to_isal(level, DEF_MEM_LEVEL)
138+
cdef unsigned int level_buf_size = zlib_mem_level_to_isal(level, DEF_MEM_LEVEL)
139139
cdef unsigned char* level_buf = <unsigned char*> PyMem_Malloc(level_buf_size * sizeof(char))
140140
isal_deflate_init(&stream)
141141
stream.level = level
@@ -146,7 +146,7 @@ def compress(data,
146146
&stream.gzip_flag)
147147

148148
# Initialise output buffer
149-
cdef unsigned long obuflen = DEF_BUF_SIZE
149+
cdef unsigned int obuflen = DEF_BUF_SIZE
150150
cdef unsigned char * obuf = <unsigned char*> PyMem_Malloc(obuflen * sizeof(char))
151151
out = []
152152

@@ -223,7 +223,7 @@ cpdef decompress(data,
223223
stream.next_in = ibuf
224224

225225
# Initialise output buffer
226-
cdef unsigned long obuflen = bufsize
226+
cdef unsigned int obuflen = bufsize
227227
cdef unsigned char * obuf = <unsigned char*> PyMem_Malloc(obuflen * sizeof(char))
228228
out = []
229229
cdef int err
@@ -281,7 +281,7 @@ cdef class Compress:
281281
cdef isal_zstream stream
282282
cdef unsigned char * level_buf
283283
cdef unsigned char * obuf
284-
cdef unsigned long obuflen
284+
cdef unsigned int obuflen
285285

286286
def __cinit__(self,
287287
int level = ISAL_DEFAULT_COMPRESSION,
@@ -394,7 +394,7 @@ cdef class Decompress:
394394
cdef bint is_initialised
395395
cdef inflate_state stream
396396
cdef unsigned char * obuf
397-
cdef unsigned long obuflen
397+
cdef unsigned int obuflen
398398

399399
def __cinit__(self, wbits=ISAL_DEF_MAX_HIST_BITS, zdict = None):
400400
isal_inflate_init(&self.stream)
@@ -451,8 +451,8 @@ cdef class Decompress:
451451
cdef unsigned char * ibuf = <unsigned char*>buffer.buf
452452
self.stream.next_in = ibuf
453453
self.stream.avail_out = 0
454-
cdef unsigned long prev_avail_out
455-
cdef unsigned long bytes_written
454+
cdef unsigned int prev_avail_out
455+
cdef unsigned int bytes_written
456456
cdef Py_ssize_t unused_bytes
457457
cdef int err
458458

@@ -510,10 +510,10 @@ cdef class Decompress:
510510
cdef unsigned char * ibuf = <unsigned char*>buffer.buf
511511
self.stream.next_in = ibuf
512512

513-
cdef unsigned long total_bytes = 0
514-
cdef unsigned long bytes_written
513+
cdef unsigned int total_bytes = 0
514+
cdef unsigned int bytes_written
515515
out = []
516-
cdef unsigned long obuflen = length
516+
cdef unsigned int obuflen = length
517517
cdef unsigned char * obuf = <unsigned char *>PyMem_Malloc(obuflen * sizeof(char))
518518
cdef Py_ssize_t unused_bytes
519519

@@ -557,8 +557,8 @@ cdef wbits_to_flag_and_hist_bits_deflate(int wbits,
557557

558558

559559
cdef wbits_to_flag_and_hist_bits_inflate(int wbits,
560-
unsigned long * hist_bits,
561-
unsigned long * crc_flag):
560+
unsigned int * hist_bits,
561+
unsigned int * crc_flag):
562562
if wbits == 0:
563563
hist_bits[0] = 0
564564
crc_flag[0] = ISAL_ZLIB

0 commit comments

Comments
 (0)