diff options
author | Nick Wellnhofer <wellnhofer@aevum.de> | 2016-06-06 18:36:15 +0200 |
---|---|---|
committer | Nick Wellnhofer <wellnhofer@aevum.de> | 2016-06-06 18:36:52 +0200 |
commit | 73829be73e3c77eb75c6b234c6626815da7da7bc (patch) | |
tree | b3da8ded0925fe2ab0e544d66df7495e77dab316 | |
parent | 45bfbcc9d2a82bb79d57aead9e51099e71e187e9 (diff) |
Fix ctypes in Python FFI calls
This didn't cause problems so far because
- all types are 32-bit on 32-bit systems and
- arguments are passed in registers on x86-64.
The wrong types could cause crashes on other platforms, though.
-rw-r--r-- | test/cmark.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/test/cmark.py b/test/cmark.py index 60eacb1..4be85a3 100644 --- a/test/cmark.py +++ b/test/cmark.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -from ctypes import CDLL, c_char_p, c_long, c_void_p +from ctypes import CDLL, c_char_p, c_size_t, c_int, c_void_p from subprocess import * import platform import os @@ -14,7 +14,7 @@ def pipe_through_prog(prog, text): def to_html(lib, text): markdown = lib.cmark_markdown_to_html markdown.restype = c_char_p - markdown.argtypes = [c_char_p, c_long, c_long] + markdown.argtypes = [c_char_p, c_size_t, c_int] textbytes = text.encode('utf-8') textlen = len(textbytes) result = markdown(textbytes, textlen, 0).decode('utf-8') @@ -25,10 +25,10 @@ def to_commonmark(lib, text): textlen = len(textbytes) parse_document = lib.cmark_parse_document parse_document.restype = c_void_p - parse_document.argtypes = [c_char_p, c_long, c_long] + parse_document.argtypes = [c_char_p, c_size_t, c_int] render_commonmark = lib.cmark_render_commonmark render_commonmark.restype = c_char_p - render_commonmark.argtypes = [c_void_p, c_long, c_long] + render_commonmark.argtypes = [c_void_p, c_int, c_int] node = parse_document(textbytes, textlen, 0) result = render_commonmark(node, 0, 0).decode('utf-8') return [0, result, ''] |