summaryrefslogtreecommitdiffstats
path: root/ffi/lang
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-01-15 17:57:35 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-01-15 18:02:37 +0100
commit977fae00f57ca87fa08568a3ce0f55a5382af13a (patch)
tree64afb0bfe2768efee998964a640fd3e24ec75505 /ffi/lang
parent1f504ddf2d09f62ea3a68aab6deeac24aa813b54 (diff)
ffi: Allocate returned strings using libc.
- Allocate all returned strings using libc's allocator. This has the advantage that the user can easily use strings and free them using free(3). - Fixes #157.
Diffstat (limited to 'ffi/lang')
-rw-r--r--ffi/lang/python/sequoia/glue.py2
-rw-r--r--ffi/lang/python/sequoia/sequoia_build.py3
2 files changed, 4 insertions, 1 deletions
diff --git a/ffi/lang/python/sequoia/glue.py b/ffi/lang/python/sequoia/glue.py
index 4b74d609..799c550c 100644
--- a/ffi/lang/python/sequoia/glue.py
+++ b/ffi/lang/python/sequoia/glue.py
@@ -84,7 +84,7 @@ class SQObject(object):
def sq_str(s):
t = ffi.string(s).decode()
- lib.sq_string_free(s)
+ lib.free(s)
return t
_str = sq_str
diff --git a/ffi/lang/python/sequoia/sequoia_build.py b/ffi/lang/python/sequoia/sequoia_build.py
index 5295243a..07dd5bb6 100644
--- a/ffi/lang/python/sequoia/sequoia_build.py
+++ b/ffi/lang/python/sequoia/sequoia_build.py
@@ -22,6 +22,9 @@ ffibuilder.set_source('_sequoia',
# cffi magic to make time_t work.
ffibuilder.cdef('typedef int... time_t;')
+# free(3)
+ffibuilder.cdef('void free (void *ptr);')
+
try:
ffibuilder.cdef(defs, override=True)
except error.CDefError as e: