Skip to content

Commit f8b811e

Browse files
committed
Adding restype and argtypes for the yajl C functions used by yajl_parse.py. As currently implemented, yajl-py fails for 64-bit architectures because ctypes defaults to a return value of c_int. That means the yajl.yajl_alloc function returns only the bottom 32-bits of a 64-bit pointer, causing segmentation faults in yajl.yajl_parse when it is used.
1 parent 2f7f69c commit f8b811e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

yajl/yajl_common.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,13 @@ def get_yajl_version():
4848
return '%s.%s.%s' %tuple(map(int, [v[:-4], v[-4:-2], v[-2:]]))
4949

5050
yajl = load_yajl()
51+
52+
yajl.yajl_alloc.restype = c_void_p
53+
yajl.yajl_alloc.argtypes = [c_void_p, c_void_p, c_void_p, c_void_p]
54+
yajl.yajl_free.argtypes = [c_void_p]
55+
yajl.yajl_parse.restype = c_int
56+
yajl.yajl_parse.argtypes = [c_void_p, c_char_p, c_int]
57+
yajl.yajl_parse_complete.restype = c_int
58+
yajl.yajl_parse_complete.argtypes = [c_void_p]
59+
yajl.yajl_get_error.restype = c_char_p
60+
yajl.yajl_get_error.argtypes = [c_void_p, c_int, c_char_p, c_int]

0 commit comments

Comments
 (0)