[gambit-list] FFI Converting std::vector to scheme-vector (best practice)
Chris Mueller
ruunsmail at gmail.com
Mon Aug 19 13:15:29 EDT 2013
On 19.08.2013 12:16, Mikael wrote:
>
> 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 |struct|, |union| 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?
>
Of course :)
;; struct definition
(c-declare "struct test { int a; int b; };")
(c-define-type struct-test (struct "test"))
(define struct-test
(c-lambda () struct-test "___result_voidstar = new test;"))
;; test code
(load "test")
(define (alloc-struct n)
(let loop ((i 0))
(if (< i n)
(let ((a (struct-test)))
(loop (+ i 1))
(write "FIN")))))
(alloc-struct 100000000000)
More information about the Gambit-list
mailing list