summaryrefslogtreecommitdiff
path: root/msgpack/_packer.pyx
diff options
context:
space:
mode:
authorINADA Naoki <methane@users.noreply.github.com>2016-04-30 17:07:14 +0900
committerINADA Naoki <methane@users.noreply.github.com>2016-04-30 17:07:14 +0900
commit6b113a6fb37ffb969e92429b06aab9ea9b8eeb4a (patch)
treea7dbd289fb4845909a17a2679e594afd27f3485d /msgpack/_packer.pyx
parent40ee322440a018c9e09634aa2c190d1747d7f0bd (diff)
downloadmsgpack-python-6b113a6fb37ffb969e92429b06aab9ea9b8eeb4a.tar.gz
Use Python's memory API (#185)
Diffstat (limited to 'msgpack/_packer.pyx')
-rw-r--r--msgpack/_packer.pyx7
1 files changed, 3 insertions, 4 deletions
diff --git a/msgpack/_packer.pyx b/msgpack/_packer.pyx
index e923895..d491cc1 100644
--- a/msgpack/_packer.pyx
+++ b/msgpack/_packer.pyx
@@ -88,7 +88,7 @@ cdef class Packer(object):
def __cinit__(self):
cdef int buf_size = 1024*1024
- self.pk.buf = <char*> malloc(buf_size);
+ self.pk.buf = <char*> PyMem_Malloc(buf_size)
if self.pk.buf == NULL:
raise MemoryError("Unable to allocate internal buffer.")
self.pk.buf_size = buf_size
@@ -97,8 +97,6 @@ cdef class Packer(object):
def __init__(self, default=None, encoding='utf-8', unicode_errors='strict',
use_single_float=False, bint autoreset=1, bint use_bin_type=0,
bint strict_types=0):
- """
- """
self.use_float = use_single_float
self.strict_types = strict_types
self.autoreset = autoreset
@@ -123,7 +121,8 @@ cdef class Packer(object):
self.unicode_errors = PyBytes_AsString(self._berrors)
def __dealloc__(self):
- free(self.pk.buf);
+ PyMem_Free(self.pk.buf)
+ self.pk.buf = NULL
cdef int _pack(self, object o, int nest_limit=DEFAULT_RECURSE_LIMIT) except -1:
cdef long long llval