<!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>&nbsp;</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&nbsp;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.&nbsp; From the htoclean 
documentation:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT><!--StartFragment -->&nbsp;&nbsp;&nbsp; When a CleanString is 
returned from C, a copy</FONT></DIV>
<DIV><FONT>&nbsp;&nbsp;&nbsp; of the string will be created in the Clean heap, 
and</FONT></DIV>
<DIV><FONT>&nbsp;&nbsp;&nbsp; this copy will be used by Clean. If the string 
was</FONT></DIV>
<DIV><FONT>&nbsp;&nbsp;&nbsp; allocated in C, for example using malloc, it 
should</FONT></DIV>
<DIV><FONT>&nbsp;&nbsp;&nbsp; be deallocated in C when it no longer used, it is 
not</FONT></DIV>
<DIV><FONT>&nbsp;&nbsp;&nbsp; automatically deallocated by Clean. </FONT><FONT 
face=Arial size=2></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Thus a&nbsp;C string returned from an 
existing&nbsp;dynamic link library</FONT></DIV>
<DIV><FONT face=Arial size=2>must first be rewrapped&nbsp;</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>&nbsp;</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&nbsp;C string&nbsp;copying it 
only once on</FONT></DIV>
<DIV><FONT face=Arial size=2>the fly directly&nbsp;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>&nbsp;</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>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Before I take time to dig 
into&nbsp;fclc.dcl/icl&nbsp; 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>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Thanks.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>John</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV></BODY></HTML>