diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-05-17 06:14:03 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-05-17 06:14:03 -0700 |
commit | e1ef72c770c20cf1c149818b12dc21df4afe4660 (patch) | |
tree | 2eff35aaa718f351096834d0f64aeb2897d73a14 /ffi.h | |
parent | 0cb8bc8048c318e32382277bdf622bd227f31168 (diff) | |
download | txr-e1ef72c770c20cf1c149818b12dc21df4afe4660.tar.gz txr-e1ef72c770c20cf1c149818b12dc21df4afe4660.tar.bz2 txr-e1ef72c770c20cf1c149818b12dc21df4afe4660.zip |
ffi: carrays able to reference objects.
The idea here is that carrays can have a pointer to some area
that is owned by another object. So that the area doesn't
disappear when the other object becomes garbage, a carray
which does this maintains a pointer to that other object.
* ffi.c (ffi_carray_get): Pass new parameter to make_carray.
(struct carray): New member, ref.
(carray_mark_op): Mark new ref member.
(make_carray): New parameter: the object which is stored in
the structure as ref.
(carray_dup): Null out the ref member. When a carray
is duplicated, it owns its own buffer, and henceforth mustn't
prevent the original object from being reclaimed.
(carray_own): Don't allow a carray to claim ownership
of the pointer if it references another object; we have
no protocol to inform that other object.
* ffi.h (make_carray): Declaration updated.
Diffstat (limited to 'ffi.h')
-rw-r--r-- | ffi.h | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -63,7 +63,7 @@ val ffi_put(val obj, val type); val ffi_in(val srcbuf, val obj, val type, val copy_p); val ffi_get(val srcbuf, val type); val ffi_out(val dstbuf, val obj, val type, val copy_p); -val make_carray(val type, mem_t *data, cnum nelem); +val make_carray(val type, mem_t *data, cnum nelem, val ref); val carray_set_length(val carray, val nelem); val carray_dup(val carray); val carray_own(val carray); |