mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
Handle freed values in refcount tests
This commit is contained in:
parent
4d2e4d454b
commit
7aa3f77b3c
2 changed files with 32 additions and 5 deletions
|
@ -300,8 +300,15 @@ where
|
|||
|
||||
let mut refcounts = Vec::with_capacity(num_refcounts);
|
||||
for i in 0..num_refcounts {
|
||||
let rc_encoded = refcount_ptrs[i].get().deref(memory).unwrap().get();
|
||||
let rc = (rc_encoded - i32::MIN + 1) as u32;
|
||||
let rc_ptr = refcount_ptrs[i].get();
|
||||
let rc = if rc_ptr.offset() == 0 {
|
||||
// RC pointer has been set to null, which means the value has been freed.
|
||||
// In tests, we simply represent this as zero refcount.
|
||||
0
|
||||
} else {
|
||||
let rc_encoded = rc_ptr.deref(memory).unwrap().get();
|
||||
(rc_encoded - i32::MIN + 1) as u32
|
||||
};
|
||||
refcounts.push(rc);
|
||||
}
|
||||
Ok(refcounts)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue