]> git.ozlabs.org Git - ccan/commit
foreach: fix case where iterators are not on the stack.
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 21 Mar 2011 03:14:22 +0000 (13:44 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 21 Mar 2011 03:14:22 +0000 (13:44 +1030)
commit34eab93cc6fbd18967810ae984b52615c995b199
tree357d8681185c988b43bd4b53450884925d03c9cf
parentd1d29462c77d909b8e7a6b960bcc71c9422e0f8f
foreach: fix case where iterators are not on the stack.

The foreach garbage collection assumed that iterators were all on the
stack, but they could be on the heap or a global (or static) variable.
We can prevent the heap case by tricky use of macros to complain on
any iterator which isn't a single token, but we can't prevent
globals/statics.

So, if an iterator already seems to be "off" the stack, mark it as
such and simply never free it.
ccan/foreach/foreach.c
ccan/foreach/test/run-not-on-stack.c [new file with mode: 0644]