2013/8/19 Chris Mueller <ruunsmail@gmail.com>
On 19.08.2013 06:13, Mikael wrote:
> std::string requires delete to be used for proper deallocation and
> free() might just partially deallocate it, no? - what about trying with
> some more ordinary struct like tm ?

Could be, but i think this is not the case. The documentation mentioned
if gambit is using g++ it should actually use 'delete (type*)
internal-pointer'.

Ah good point.
 

I've also checked this with a POD struct:

struct test { int A; int B }

It's no difference if
   * struct test is allocated with new
   * struct test is allocated with malloc

It's also leaking memory.


So the manual goes:

When the release-function is not specified or is #f a default function is constructed by the C-interface.

(This is the case here.) 

This default function does nothing in the case of the pointer and nonnull-pointer types (deallocation is not the responsibility of the C-interface) and returns the fixnum ‘___FIX(___NO_ERR)’ to indicate no error.

So in your past test with a pointered type, you did see the proper behavior.  And here comes what applies to the current test:

In the case of the structunion and type 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 ‘delete (type*)internal-pointer’, which calls the destructor of type if it is a class) and returns ‘___FIX(___NO_ERR)’.

 
Can you paste your full test code here?

Mikael









_______________________________________________
Gambit-list mailing list
Gambit-list@iro.umontreal.ca
https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list