<?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="2003/07/bbf60d825fc8b08ddc054bb6ccbbeb48"
  from="Neil Conway &lt;neilc@s...&gt;"
  author="Neil Conway"
  date="2003-07-02T01:20:46"
  subject="[Caml-list] alloc_final and local value variables"
  prev="2003/07/048faa0f5ab032b75abc596f2cb84132"
  next="2003/07/d3684049ef97610c271443c5f8c1c003"
  next-in-thread="2003/07/3444f9db4683b79f42ccc688703d54b7"
  prev-thread="2003/07/344b723b56e3139d35f2009777e68d31"
  next-thread="2003/07/d3684049ef97610c271443c5f8c1c003"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] alloc_final and local value variables">
<msg 
  url="2003/07/bbf60d825fc8b08ddc054bb6ccbbeb48"
  from="Neil Conway &lt;neilc@s...&gt;"
  author="Neil Conway"
  date="2003-07-02T01:20:46"
  subject="[Caml-list] alloc_final and local value variables">
<msg 
  url="2003/07/3444f9db4683b79f42ccc688703d54b7"
  from="John Max Skaller &lt;skaller@o...&gt;"
  author="John Max Skaller"
  date="2003-07-03T10:35:06"
  subject="Re: [Caml-list] alloc_final and local value variables">
</msg>
</msg>
</thread>

<contents>
In Chapter 12 of the O'Reilly book on Ocaml, section "Creating and modifying
Objective CAML values from C", this example code is given for wrapping a
heap-allocated chunk of memory in an Ocaml value:

value create (value s)
{
  value block ;
  block = alloc_final (2, finalize_it,Int_val(s)*sizeof(IntTab),100000) ;
  Field(block,1) = (value) alloc_it(Int_val(s)) ;
  return block ;
}

This code uses a "value" local, but doesn't declare it with one of the
CAMLlocalN variables, as the Ocaml Manual says is necessary (Ocaml Manual,
"Interfacing C with Objective Caml", Section 18.5.1, Rule 2). Is this code
above correct?

Thanks in advance,

Neil

P.S. I'm aware that custom blocks are now available, but alloc_final does
everything I need...

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

</contents>

</message>

