On 10/01/2015 06:08 PM, Marijn Schraagen wrote:
> Hi,
>
> Using the foreign interface I try to store a term reference in a loop if
> a condition is met. However, the reference turns out to become invalid
> if there are other Prolog calls in between.
PL_copy_term_ref() creates a second reference to the same term, but
does not change the scoping of the term. If you call PL_next_solution()
in a loop, you basically backtrack, resetting all terms to the state
before the first call to PL_next_solution(). If you want to remember
things, there is PL_record() and friends. But, these make copies of
the term and you must get rid of them explicitly do avoid memory leaks.
Hope this helps
--- Jan
> --
> You received this message because you are subscribed to the Google
> Groups "SWI-Prolog" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
swi-prolog+...@googlegroups.com
> <mailto:
swi-prolog+...@googlegroups.com>.
> Visit this group at
http://groups.google.com/group/swi-prolog.
> For more options, visit
https://groups.google.com/d/optout.