summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordzaima <dzaimagit@gmail.com>2024-02-05 22:42:24 +0200
committerdzaima <dzaimagit@gmail.com>2024-02-05 22:42:24 +0200
commit05ceb45b2f647534c1d2f82e948ba56c8cfb785c (patch)
treeedb67eff61af693a79bcf9374abb5ca738741a5e
parent19f4b1293d06f80c898889d1c2048472d8ad4a49 (diff)
fix ptr.Write doing weird things
-rw-r--r--src/ffi.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/ffi.c b/src/ffi.c
index 0774dc24..d1f7673d 100644
--- a/src/ffi.c
+++ b/src/ffi.c
@@ -695,7 +695,7 @@ static void genObj_ptr(void* res, B c, B expEl) {
ffiObjsGlobal = vec_addN(ffiObjsGlobal, incG(c));
*(void**)res = ptrh_ptr(h);
}
-void genObj(B o, B c, bool anyMut, void* ptr) { // doesn't consume
+void genObj(B o, B c, bool anyMut, void* ptr) { // doesn't consume; mutates ffiObjsGlobal
// printFFIType(stdout,o); printf(" = "); printI(c); printf("\n");
if (isC32(o)) { // scalar
u32 t = styG(o);
@@ -1243,7 +1243,10 @@ static B ptrobjRead_c1(B t, B x) {
}
static B ptrobjWrite_c2(B t, B w, B x) {
B h = nfn_objU(t);
+ ffiObjsGlobal = emptyHVec();
genObj(ptrh_type(h), x, false, ptrobj_elbase(h, w, false));
+ decG(ffiObjsGlobal);
+
dec(x);
return m_f64(1);
}