<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">2013/8/19 Chris Mueller <span dir="ltr"><<a href="mailto:ruunsmail@gmail.com" target="_blank">ruunsmail@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<div class="im">On 19.08.2013 06:13, Mikael wrote:<br>
> std::string requires delete to be used for proper deallocation and<br>
> free() might just partially deallocate it, no? - what about trying with<br>
> some more ordinary struct like tm ?<br>
<br>
</div>Could be, but i think this is not the case. The documentation mentioned<br>
if gambit is using g++ it should actually use 'delete (type*)<br>
internal-pointer'.<br></blockquote><div><br></div><div>Ah good point.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">


<br>
I've also checked this with a POD struct:<br>
<br>
struct test { int A; int B }<br>
<br>
It's no difference if<br>
   * struct test is allocated with new<br>
   * struct test is allocated with malloc<br>
<br>
It's also leaking memory.<br></blockquote><div><br></div><div><br></div><div>So the manual goes:</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<span style="color:rgb(0,0,0);font-family:'Times New Roman';font-size:medium">When the </span><var style="color:rgb(0,0,0);font-family:'Times New Roman';font-size:medium">release-function</var><span style="color:rgb(0,0,0);font-family:'Times New Roman';font-size:medium"> is not specified or is </span><code style="color:rgb(0,0,0)">#f</code><span style="color:rgb(0,0,0);font-family:'Times New Roman';font-size:medium"> a default function is constructed by the C-interface. </span></blockquote>

<div><br></div><div>(This is the case here.) </div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<span style="color:rgb(0,0,0);font-family:'Times New Roman';font-size:medium">This default function does nothing in the case of the </span><code style="color:rgb(0,0,0)">pointer</code><span style="color:rgb(0,0,0);font-family:'Times New Roman';font-size:medium"> and </span><code style="color:rgb(0,0,0)">nonnull-pointer</code><span style="color:rgb(0,0,0);font-family:'Times New Roman';font-size:medium"> types (deallocation is not the responsibility of the C-interface) and returns the fixnum ‘</span><samp style="color:rgb(0,0,0)">___FIX(___NO_ERR)</samp><span style="color:rgb(0,0,0);font-family:'Times New Roman';font-size:medium">’ to indicate no error. </span></blockquote>

<div><br></div><div>So in your past test with a pointered type, you did see the proper behavior.  And here comes what applies to the current test:</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<span style="color:rgb(0,0,0);font-family:'Times New Roman';font-size:medium">In the case of the </span><code style="color:rgb(0,0,0)">struct</code><span style="color:rgb(0,0,0);font-family:'Times New Roman';font-size:medium">, </span><code style="color:rgb(0,0,0)">union</code><span style="color:rgb(0,0,0);font-family:'Times New Roman';font-size:medium"> and </span><code style="color:rgb(0,0,0)">type</code><span style="color:rgb(0,0,0);font-family:'Times New Roman';font-size:medium"> types, the default function reclaims the copy on the C heap referenced by the internal pointer (when using a C++ compiler this is done using ‘</span><samp style="color:rgb(0,0,0)">delete (<var>type</var>*)<var>internal-pointer</var></samp><span style="color:rgb(0,0,0);font-family:'Times New Roman';font-size:medium">’, which calls the destructor of </span><var style="color:rgb(0,0,0);font-family:'Times New Roman';font-size:medium">type</var><span style="color:rgb(0,0,0);font-family:'Times New Roman';font-size:medium"> if it is a class) and returns ‘</span><samp style="color:rgb(0,0,0)">___FIX(___NO_ERR)</samp><span style="color:rgb(0,0,0);font-family:'Times New Roman';font-size:medium">’.</span></blockquote>

<div><br></div><div> </div><div>Can you paste your full test code here?</div><div><br></div><div>Mikael</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">


<div class=""><div class="h5"><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
Gambit-list mailing list<br>
<a href="mailto:Gambit-list@iro.umontreal.ca">Gambit-list@iro.umontreal.ca</a><br>
<a href="https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list" target="_blank">https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list</a><br>
</div></div></blockquote></div><br></div></div>