[plt-scheme] passing pointer from one FFI call as input into another FFI call

From: Scott Hickey (sshickey at qwest.net)
Date: Fri Jun 19 01:09:35 EDT 2009

I have a C function that allocates a linked list of structs and it
works great until I try to pass it into another C function.

(define-cstruct _st_marker ([timestamp _int] [offset _int] [value
_int] [next _st_marker/null]))

;; int get_markers(char *filename, struct st_marker **marker_list)

(define get-markers
  (get-ffi-obj "get_markers" "libvfm"
               (_fun _string [markers : (_ptr o _st_marker-pointer/
null)]
                     -> [status : _int] -> (values markers status))))

I want to pass the value returned in 'markers' above to the function
below:

;; int create_event_list_from_marker_list(struct st_marker
*marker_list, struct st_event **event_list)

(define create-event-list-from-marker-list
  (get-ffi-obj "create_event_list_from_marker_list" "libvfm"
               (_fun [markers : (_ptr i _st_marker-pointer/null)]
                     [events : (_ptr o _st_event-pointer/null)]
                     -> [status : _int] -> (values events status))))


After searching for information on this, I saw on message that said
there are problems reusing the data bound using _ptr o  as input into
another C function. Is there a different syntax I can use to
accomplish this?

Thanks,

Scott Hickey



Posted on the users mailing list.