@@ -229,10 +229,12 @@ def decompress(data,
229229 """
230230 cdef unsigned int hist_bits
231231 cdef unsigned int flag
232+ cdef bint is_gzip
233+ data_is_gzip(data, & is_gzip)
232234 wbits_to_flag_and_hist_bits_inflate(wbits,
233235 & hist_bits,
234236 & flag,
235- data_is_gzip(data) )
237+ is_gzip )
236238 return igzip_decompress(data, flag, hist_bits, bufsize)
237239
238240
@@ -416,6 +418,7 @@ cdef class Decompress:
416418 cdef public bint eof
417419 cdef inflate_state stream
418420 cdef bint method_set
421+ cdef bint is_gzip
419422
420423 def __cinit__ (self , int wbits = ISAL_DEF_MAX_HIST_BITS, zdict = None ):
421424 isal_inflate_init(& self .stream)
@@ -490,7 +493,8 @@ cdef class Decompress:
490493
491494 if not self .method_set:
492495 # Try to detect method from the first two bytes of the data.
493- self .stream.crc_flag = ISAL_GZIP if data_is_gzip(data) else ISAL_ZLIB
496+ data_is_gzip(data, & self .is_gzip)
497+ self .stream.crc_flag = ISAL_GZIP if self .is_gzip else ISAL_ZLIB
494498 self .method_set = 1
495499
496500 # initialise input
@@ -576,20 +580,23 @@ cdef class Decompress:
576580 PyBuffer_Release(buffer )
577581 PyMem_Free(obuf)
578582
579- cdef bint data_is_gzip(object data):
583+ cdef data_is_gzip(object data, bint * is_gzip ):
580584 cdef Py_buffer buffer_data
581585 cdef Py_buffer* buffer = & buffer_data
582586 PyObject_GetBuffer(data, buffer , PyBUF_C_CONTIGUOUS)
583587 if buffer .len < 2 :
584588 PyBuffer_Release(buffer )
585- return False
589+ is_gzip[0 ] = False
590+ return
586591 cdef unsigned char * char_ptr = < unsigned char * > buffer .buf
587592 if char_ptr[0 ] == 31 :
588593 if char_ptr[1 ] == 139 :
589594 PyBuffer_Release(buffer )
590- return True
595+ is_gzip[0 ] = True
596+ return
591597 PyBuffer_Release(buffer )
592- return False
598+ is_gzip[0 ] = False
599+ return
593600
594601
595602cdef wbits_to_flag_and_hist_bits_deflate(int wbits,
0 commit comments