C-Interface (Memory Management)

Peter Herkenrath P.Herkenrath at rrz.uni-koeln.de
Tue Nov 10 12:59:15 AEDT 1998


Hi folks,
as an old Perl addict I missed pattern matching in Mercury. 
I wanted to reuse an Sicstus interface to the regex library (prolog-rx
by Gerd van Noord).
The C function regex_match should return the matched substrings as a
list(string) type. Such a case is not mentioned in the Language
Reference
and not demonstrated in samples/c_interface.
After much try and error I finally managed to make a (mostly) working
interface to the regex library. The strings were allocated via
make_many(), 4cons4ed by an Mercury function, ... .
The general questions:
Is this the 4right4 way to allocate memory for an object which will be
used by Mercury?
When (and how) should such Objects be deallocated (via oldmem?)?

many thanks

Peter Herkenrath



More information about the users mailing list