| 1 |
<!DOCTYPE html> |
| 2 |
<html lang="en"> |
| 3 |
<head> |
| 4 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| 5 |
<meta name="generator" content="hevea 2.35"> |
| 6 |
<link rel="stylesheet" type="text/css" href="main.css"> |
| 7 |
<title>Release notes</title> |
| 8 |
</head> |
| 9 |
<body > |
| 10 |
<a href="main005.html"><img src="previous_motif.svg" alt="Previous"></a> |
| 11 |
<a href="index.html"><img src="contents_motif.svg" alt="Up"></a> |
| 12 |
<hr> |
| 13 |
<h2 id="sec41" class="section">6 Release notes</h2> |
| 14 |
<p>Here are some caveats and open issues that apply to the current |
| 15 |
release.</p> |
| 16 |
<h4 id="sec42" class="paragraph">Deallocation of function results and <span class=machine><span class=font-tt>out</span></span> parameters:</h4> |
| 17 |
<p> |
| 18 |
If a C function dynamically allocates some of its outputs (either |
| 19 |
returned or stored in <span class=machine><span class=font-tt>out</span></span> parameters), its IDL declaration must |
| 20 |
contain a <span class=syntax-token>quote(dealloc,</span> <a href="main002.html#string" class="syntax"><span class=nonterminal>string</span></a> <span class=syntax-token>)</span> clause to properly free the |
| 21 |
space occupied by those outputs after they have been converted to |
| 22 |
Caml. Otherwise, memory leaks will occur. (The only exception is |
| 23 |
results and output parameters of type <span class=machine><span class=font-tt>[bigarray,managed] </span></span><span class=font-it>ty</span><span class=machine><span class=font-tt>[]</span></span>, |
| 24 |
where the Caml garbage collector takes care of deallocation.)</p><p>This does not conform to the MIDL and COM specifications, which say |
| 25 |
that space for <span class=machine><span class=font-tt>out</span></span> data structures must be allocated |
| 26 |
with <span class=machine><span class=font-tt>CoTaskMemAlloc</span></span> by the callee, and automatically freed |
| 27 |
using <span class=machine><span class=font-tt>CoTaskMemFree</span></span> by the generated stub code. (The specs don’t |
| 28 |
say what happens with the return value of the function.) |
| 29 |
However, there are many functions in Win32 (not to mention the |
| 30 |
Unix world) that do not follow this convention, and |
| 31 |
return data structures (e.g. strings) that are statically |
| 32 |
allocated, or require special deallocation functions. Hence, |
| 33 |
<span class=machine><span class=font-tt>camlidl</span></span> leaves deallocation of outputs entirely under user control.</p> |
| 34 |
<h4 id="sec43" class="paragraph">Allocation and deallocation of <span class=machine><span class=font-tt>in,out</span></span> parameters:</h4> |
| 35 |
<p> |
| 36 |
For <span class=machine><span class=font-tt>in,out</span></span> parameters, the MIDL/COM rules are that the caller (the |
| 37 |
stub code) should allocate the inputs, the callee should free them |
| 38 |
and allocate again its outputs, and the caller should free the outputs. |
| 39 |
As explained above, <span class=machine><span class=font-tt>camlidl</span></span>-generated stubs don’t automatically free |
| 40 |
the outputs. Worse, the inputs passed to the functions are allocated |
| 41 |
partially on the stack and partially in the heap |
| 42 |
(using <span class=machine><span class=font-tt>CoTaskMemAlloc</span></span>), so the callee may perform an incorrect |
| 43 |
free on a stack-allocated argument. The best thing to do is avoid |
| 44 |
<span class=machine><span class=font-tt>in,out</span></span> parameters entirely, and split them into one <span class=machine><span class=font-tt>in</span></span> and one |
| 45 |
<span class=machine><span class=font-tt>out</span></span> parameter.</p> |
| 46 |
<h4 id="sec44" class="paragraph">Reference-counting of COM interfaces:</h4> |
| 47 |
<p> |
| 48 |
Caml finalized objects are used to call <span class=machine><span class=font-tt>Release</span></span> automatically on COM |
| 49 |
interfaces that become unreachable. The reference counting of |
| 50 |
interfaces passed as <span class=machine><span class=font-tt>in</span></span> and <span class=machine><span class=font-tt>out</span></span> parameters is correctly |
| 51 |
implemented. However, <span class=machine><span class=font-tt>in,out</span></span> parameters that are interfaces are not |
| 52 |
correctly handled. Again, avoid <span class=machine><span class=font-tt>in,out</span></span> parameters.</p> |
| 53 |
<h4 id="sec45" class="paragraph">COM support:</h4> |
| 54 |
<p> |
| 55 |
The support for COM is currently quite small. COM components |
| 56 |
registered in the system registry can be imported via |
| 57 |
<span class=machine><span class=font-tt>Com.create</span></span><span class=machine><span class=font-tt>_</span></span><span class=machine><span class=font-tt>instance</span></span>. Components written in Caml can be exported as |
| 58 |
DLLs, but not yet as standalone servers. Preliminary support for |
| 59 |
dispatch interfaces is available, however many of the data types used |
| 60 |
in the Automation framework are not supported yet (e.g. <span class=machine><span class=font-tt>SAFEARRAY</span></span>). |
| 61 |
</p><hr> |
| 62 |
<a href="main005.html"><img src="previous_motif.svg" alt="Previous"></a> |
| 63 |
<a href="index.html"><img src="contents_motif.svg" alt="Up"></a> |
| 64 |
</body> |
| 65 |
</html> |