summaryrefslogtreecommitdiffstats
path: root/lib.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-08-29 07:29:09 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-08-29 07:29:09 -0700
commit13da0e5ed3d3d4be6d1f9cc9d786ff4e0f2edd68 (patch)
tree7ae339fc0501087c3c3c4c5c45c3d0c592afb995 /lib.h
parent9f142b398f53ab7844a0fdfc5b562e8bbccfebe2 (diff)
downloadtxr-13da0e5ed3d3d4be6d1f9cc9d786ff4e0f2edd68.tar.gz
txr-13da0e5ed3d3d4be6d1f9cc9d786ff4e0f2edd68.tar.bz2
txr-13da0e5ed3d3d4be6d1f9cc9d786ff4e0f2edd68.zip
seq_iter: fix gc issues.
* lib.h (struct seq_iter_ops): New operation, mark. (seq_iter_ops_init): Default the mark operation to seq_iter_mark_op. (seq_iter_ops_init_nomark): New macro. * lib.c (seq_iter_mark_op): New static function. (si_range_cnum_ops, si_range_chr_ops, si_rev_range_cnum_ops, si_rev_range_chr_ops, si_chr_ops): Initialize with seq_iter_ops_init_nomark so that the iterator has no mark operation. All other iterator types have the above new static function as their mark op. (seq_iter_mark): Simplified: if the iterator has a mark op, call it. (seq_next, iter_step): If the iterator has a mark op, that means that the seq_get operation is likely replacing one heap object with another, and so mut(iter) must be called to inform the garbage collector of the assignment.
Diffstat (limited to 'lib.h')
-rw-r--r--lib.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib.h b/lib.h
index 3365183c..76ad19b2 100644
--- a/lib.h
+++ b/lib.h
@@ -421,9 +421,11 @@ typedef struct seq_iter {
struct seq_iter_ops {
int (*get)(struct seq_iter *, val *pval);
int (*peek)(struct seq_iter *, val *pval);
+ void (*mark)(struct seq_iter *);
};
-#define seq_iter_ops_init(get, peek) { get, peek }
+#define seq_iter_ops_init(get, peek) { get, peek, seq_iter_mark_op }
+#define seq_iter_ops_init_nomark(get, peek) { get, peek, 0 }
extern const seq_kind_t seq_kind_tab[MAXTYPE+1];