leptonica: serialization tweaks, memory handling
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user