summaryrefslogtreecommitdiff
path: root/python/msgpack.pyx
diff options
context:
space:
mode:
authorNaoki INADA <inada-n@gear>2009-06-09 13:12:29 +0900
committerNaoki INADA <inada-n@gear>2009-06-09 13:12:29 +0900
commit85ca59411868ab84d874ad28e56213f5374e5ca8 (patch)
tree498e012ef088ba805b3432c6c8e1aa2b63a06075 /python/msgpack.pyx
parent9c9393bff919fa4ad9e8ff64feaf28859a0c22e6 (diff)
downloadmsgpack-python-85ca59411868ab84d874ad28e56213f5374e5ca8.tar.gz
free buffer when packer deleted.
Diffstat (limited to 'python/msgpack.pyx')
-rw-r--r--python/msgpack.pyx9
1 files changed, 8 insertions, 1 deletions
diff --git a/python/msgpack.pyx b/python/msgpack.pyx
index 8b2006a..f24f403 100644
--- a/python/msgpack.pyx
+++ b/python/msgpack.pyx
@@ -59,6 +59,8 @@ cdef class Packer:
msgpack_packer_init(&self.pk, <void*>self, <msgpack_packer_write>_packer_write)
+ def __del__(self):
+ free(self.buff);
def flush(self):
"""Flash local buffer and output stream if it has 'flush()' method."""
@@ -98,7 +100,7 @@ cdef class Packer:
"""
msgpack_pack_map(&self.pk, len)
- def pack(self, object o):
+ cdef __pack(self, object o):
cdef long long intval
cdef double fval
cdef char* rawval
@@ -140,6 +142,11 @@ cdef class Packer:
# TODO: Serialize with defalt() like simplejson.
raise TypeError, "can't serialize %r" % (o,)
+ def pack(self, obj, flush=True):
+ self.__pack(obj)
+ if flush:
+ self.flush()
+
cdef int _packer_write(Packer packer, const_char_ptr b, unsigned int l):
if packer.length + l > packer.allocated:
if packer.length > 0: