[PPL-devel] Re: Bignums and the foreign language interface

Roberto Bagnara bagnara at cs.unipr.it
Tue Jan 7 21:39:07 CET 2003


Manuel Carro wrote:
> Roberto Bagnara writes:
>>>If, as I suppose, the char* obtained with
>>>`ciao_get_number_chars(ciao_term term)' is under the responsibility
>>>of the Prolog engine, its lifetime should be documented.
> 
> 
>     No, it is not: its management is passed on to the C side.  The
> documentation reads:
> 
> @item @tt{char *ciao_get_number_chars(ciao_term term);}
> 
> It converts @tt{ciao_term} (which must be instantiated to a number)
> into a C string representing the number in the current radix.  The
> string returned is a copy, to be explicitly deallocated by the user C
> code.

Right.  Perhaps it is better to be clear about which deallocation function
should be used.  In principle, the Prolog engine may obtain memory in different
ways and you may want not to commit yourself to some specific memory allocator.
Would it be a good idea to abstract all this by adding macros like
ciao_malloc() and ciao_free() to ciao_prolog.h and then instruct the user
to use ciao_free() to release the memory returned by ciao_get_number_chars()?

>>>If this is not too much, I would prefer obtaining a development snapshot
>>>of Ciao.  I still have problems with the foreign language interface
>>>and I hope they are caused by bugs you have already fixed ;-)
> 
> 
>     No problem at all. 

Thanks!

     Roberto

-- 
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara at cs.unipr.it




More information about the PPL-devel mailing list