<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2604" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>The FFI (foreign function interface) allows you to
pass</FONT></DIV>
<DIV><FONT face=Arial size=2>CleanString's from C returning them to
Clean.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>But these CleanString's are then immediately
copied</FONT></DIV>
<DIV><FONT face=Arial size=2>bringing the string data back across the
garbage collecting</FONT></DIV>
<DIV><FONT face=Arial size=2>perimeter within the purview of Clean's
memory</FONT></DIV>
<DIV><FONT face=Arial size=2>management. From the htoclean
documentation:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT><!--StartFragment --> When a CleanString is
returned from C, a copy</FONT></DIV>
<DIV><FONT> of the string will be created in the Clean heap,
and</FONT></DIV>
<DIV><FONT> this copy will be used by Clean. If the string
was</FONT></DIV>
<DIV><FONT> allocated in C, for example using malloc, it
should</FONT></DIV>
<DIV><FONT> be deallocated in C when it no longer used, it is
not</FONT></DIV>
<DIV><FONT> automatically deallocated by Clean. </FONT><FONT
face=Arial size=2></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Thus a C string returned from an
existing dynamic link library</FONT></DIV>
<DIV><FONT face=Arial size=2>must first be rewrapped </FONT><FONT
face=Arial size=2>as a CleanString in a second layer C</FONT></DIV>
<DIV><FONT face=Arial size=2>wrapper for the DLL </FONT><FONT face=Arial
size=2>and finally copied a second time by Clean.</FONT></DIV>
<DIV><FONT face=Arial size=2>So in effect I'm triple </FONT><FONT face=Arial
size=2>buffering every string crossing </FONT><FONT face=Arial size=2>the FFI
frontier</FONT></DIV>
<DIV><FONT face=Arial size=2>in bound to Clean land.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>My question is can htoclean and the Clean runtime
be modified</FONT></DIV>
<DIV><FONT face=Arial size=2>to receive a returned C string copying it
only once on</FONT></DIV>
<DIV><FONT face=Arial size=2>the fly directly into </FONT><FONT face=Arial
size=2>the final Clean string within </FONT><FONT face=Arial size=2>the
garbaging</FONT></DIV>
<DIV><FONT face=Arial size=2>collecting perimeter?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I want to write a FFI to the </FONT><FONT
face=Arial size=2>MySQL database dynamic link library</FONT></DIV>
<DIV><FONT face=Arial size=2>and I'm forced to wrap another </FONT><FONT
face=Arial size=2>C layer around it and handle the</FONT></DIV>
<DIV><FONT face=Arial size=2>malloc/frees simply for this third buffer and
performance suffers.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Before I take time to dig
into fclc.dcl/icl I just wanted to know if this</FONT></DIV>
<DIV><FONT face=Arial size=2>is a mission impossible.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Thanks.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>John</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV></BODY></HTML>