Skip to content

Commit

Permalink
Adding restype and argtypes for the yajl C functions used by yajl_par…
Browse files Browse the repository at this point in the history
…se.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.
  • Loading branch information
cgordon committed Feb 12, 2011
1 parent 2f7f69c commit f8b811e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions yajl/yajl_common.py
Expand Up @@ -48,3 +48,13 @@ def get_yajl_version():
return '%s.%s.%s' %tuple(map(int, [v[:-4], v[-4:-2], v[-2:]]))

yajl = load_yajl()

yajl.yajl_alloc.restype = c_void_p
yajl.yajl_alloc.argtypes = [c_void_p, c_void_p, c_void_p, c_void_p]
yajl.yajl_free.argtypes = [c_void_p]
yajl.yajl_parse.restype = c_int
yajl.yajl_parse.argtypes = [c_void_p, c_char_p, c_int]
yajl.yajl_parse_complete.restype = c_int
yajl.yajl_parse_complete.argtypes = [c_void_p]
yajl.yajl_get_error.restype = c_char_p
yajl.yajl_get_error.argtypes = [c_void_p, c_int, c_char_p, c_int]

0 comments on commit f8b811e

Please sign in to comment.