On Sat, Jun 15, 2013 at 1:55 PM, Roman Klochkov <[email protected]> wrote:
> What about > > (define-lib foo (fun _string -> _void)) > > (foo "Test") > > ? > > Will be the pointer from string "Test" freed? > I *think* Racket will garbage collect the "Test" value when it is not used anymore on the Racket side, but it won't know what happens on the ffi C side (hence the "ffi/unsafe"). So I think the lib may point to a freed value if you're not cautious. > And how to make it retain, if I need to save it on the foreign side? > You can probably at least simply store it in a global variable. There may be a better way to do it though. For example (not tested) : #lang racket (define dontfreethem '()) (define (dontfreeme x) (set! dontfreethem (cons x dontfreethem)) x) (foo (dontfreeme "Test")) Laurent
____________________ Racket Users list: http://lists.racket-lang.org/users

