Hi, just want to make sure this code is legal.  I have a C function
which allocates a string and returns it via one of its arguments,
expecting the caller to free it.  The following code works as
expected, but I want to make sure it is valid.

(let-location ((out c-string*))
  (let ((rv (my-func "Lambda.OrG" #$out "Nameprep" 0)))
    (let ((out out))           ; free out once
      (if (eqv? rv 0)
          (print out)
          (error "profile error" rv)))))

The issue is that ##sys#peek-and-free-c-string will be called every
time "out" is referenced.    To guarantee "out" is freed exactly once,
I immediately rebind out to itself after the call.  Is this a valid
recipe?

Zb


_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to