Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update quicklz to 1.5.0 #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions quicklz.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__author__ = "davies <[email protected]>"
__version__ = "1.4.1"
__version__ = "1.5.0"
__copyright__ = "Copyright (C) 2010 douban.com"
__license__ = "Apache License 2.0"

Expand All @@ -8,9 +8,7 @@ from libc.stdlib cimport malloc, free
from cpython cimport PyBytes_AsStringAndSize, PyBytes_FromStringAndSize

cdef extern from "src/quicklz.h":
cdef enum:
QLZ_SCRATCH_COMPRESS
QLZ_SCRATCH_DECOMPRESS
int qlz_get_setting(int setting) nogil
size_t qlz_size_decompressed(char *source) nogil
size_t qlz_size_compressed(char *source) nogil
size_t qlz_decompress(char *source, void *destination, char *scratch_decompress) nogil
Expand All @@ -27,7 +25,7 @@ def compress(bytes val):
PyBytes_AsStringAndSize(val, &src, &vlen)
dst = <char *>malloc(vlen + 400)
with nogil:
wbuf = <char *>malloc(QLZ_SCRATCH_COMPRESS)
wbuf = <char *>malloc(qlz_get_setting(1))
csize = qlz_compress(src, dst, vlen, wbuf)
free(wbuf)

Expand All @@ -36,7 +34,7 @@ def compress(bytes val):
return val

def decompress(bytes val):
cdef char wbuf[QLZ_SCRATCH_DECOMPRESS]
cdef char *wbuf
cdef char *src
cdef char *dst
cdef Py_ssize_t slen, dlen
Expand All @@ -47,7 +45,9 @@ def decompress(bytes val):
raise ValueError('compressed length not match %d!=%d' % (slen, qlz_size_compressed(src)))
dst = <char*> malloc(qlz_size_decompressed(src))
with nogil:
wbuf = <char *>malloc(qlz_get_setting(2))
dlen = qlz_decompress(src, dst, wbuf)
free(wbuf)

val = PyBytes_FromStringAndSize(dst, dlen);
free(dst)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from setuptools import setup, Extension
setup(
name='pyquicklz',
version='1.4.1',
version='1.5.0',
description='python binding of quicklz',
setup_requires=['Cython >= 0.18'],
ext_modules=[
Expand Down
Loading