<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2006/02/527ddd47b86baf1da1e3ea70a1b7c810"
  from="Robert Roessler &lt;roessler@r...&gt;"
  author="Robert Roessler"
  date="2006-02-22T21:36:55"
  subject="Re: [Caml-list] c binding question"
  prev="2006/02/1d88b152a98eeeae0b50e9751bda9864"
  next="2006/02/25d9a1f031962f5f00379f4c2414f740"
  prev-in-thread="2006/02/ee926bfa649e1a9b3e8554e36e4b508c"
  prev-thread="2006/02/0c849ce0eedc6071b2d28d2387ff51c6"
  next-thread="2006/02/87a1efa1120fa1c00063e2d9e57ff280"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="c binding question">
<msg 
  url="2006/02/ee926bfa649e1a9b3e8554e36e4b508c"
  from="Michael Wohlwend &lt;micha-1@f...&gt;"
  author="Michael Wohlwend"
  date="2006-02-22T08:09:23"
  subject="c binding question">
<msg 
  url="2006/02/527ddd47b86baf1da1e3ea70a1b7c810"
  from="Robert Roessler &lt;roessler@r...&gt;"
  author="Robert Roessler"
  date="2006-02-22T21:36:55"
  subject="Re: [Caml-list] c binding question">
</msg>
</msg>
</thread>

<contents>
Michael Wohlwend wrote:
&gt; I want to make an interface to a c-lib in which some function take a char* as 
&gt; a parameter and store this paramenter in their internal variables.
&gt; I have done this this way:
&gt; 
&gt; I copy the ocaml-string to a new c-string and I allocated a custom block to 
&gt; store the abstract datatype of the lib together with the allocated char* for 
&gt; that string. The finalize function of that custom block releases the 
&gt; allocated memory of the string and cleans up the rest... 
&gt; 
&gt; Is this the correct way to do this? 

Sounds reasonable to me - this is essentially what I do in LablPCRE.

In that case, the PCRE regcomp call fills in a local data structure 
with (among other things) a pointer to malloc'ed storage... a custom 
block is created, the struct is copied into it, and then a finalize 
function uses PCRE's regfree call to clean up.

Robert Roessler
roessler@rftp.com
http://www.rftp.com

</contents>

</message>

