next up previous contents index
Next: Foreign Code and Modules Up: The Foreign Include File Previous: Initiating a query from   Contents   Index

Discarding Data

The Prolog data created and term-references needed to setup the call and/or analyse the result can in most cases be discarded right after the call. PL_close_query allows for destructing the data, while leaving the term-references. The calls below may be used to destroy term-references and data. See calling for an example.

fid_tPL_open_foreign_frame Created a foreign frame, holding a mark that allows the system to undo bindings and destroy data created after it as well as providing the environment for creating term-references. This function is called by the kernel before calling a foreign predicate. voidPL_close_foreign_framefid_t id Discard all term-references created after the frame was opened. All other Prolog data is retained. This function is called by the kernel whenever a foreign function returns control back to Prolog. voidPL_discard_foreign_framefid_t id Same as PL_close_foreign_frame, but also undo all bindings made since the open and destroy all Prolog data. voidPL_rewind_foreign_framefid_t id Undo all bindings and discard all term-references created since the frame was created, but does not pop the frame. I.e. the same frame can be rewinded multiple times, and must eventually be closed or discarded.

It is obligatory to call either of the two closing functions to discard a foreign frame. Foreign frames may be nested.

Figure: Calling Prolog
\begin{figure}\par\begin{code}
int
count_atoms()
{ fid_t fid = PL_open_foreign_f...
...d_foreign_frame(fid);
\par return atoms;
}
\end{code}\par\noindent
\end{figure}


next up previous contents index
Next: Foreign Code and Modules Up: The Foreign Include File Previous: Initiating a query from   Contents   Index
Dr. Richard Botting 2001-12-12