leptonica: serialization tweaks, memory handling

This commit is contained in:
James R. Barlow
2016-02-20 02:54:53 -08:00
parent 46c204f533
commit ea4e6bf67d
2 changed files with 4 additions and 1 deletions
+1 -1
View File
@@ -19,7 +19,6 @@ from .lib._leptonica import ffi
from functools import lru_cache
lept = ffi.dlopen(find_library('lept'))
libc = ffi.dlopen(None)
logger = logging.getLogger(__name__)
@@ -120,6 +119,7 @@ class Pix:
char_data = ffi.cast('char *', data[0])
data_bytes = ffi.buffer(char_data, size[0])[:]
lept.lept_free(char_data)
return dict(data=data_bytes)
def __setstate__(self, state):
+3
View File
@@ -61,7 +61,10 @@ l_int32 * makePixelSumTab8 ( void );
PIX * pixDeserializeFromMemory ( const l_uint32 *data, size_t nbytes );
l_int32 pixSerializeToMemory ( PIX *pixs, l_uint32 **pdata, size_t *pnbytes );
void lept_free(void *ptr);
""")
if __name__ == '__main__':
ffi.compile()