I think I might have been unclear about what I was asking. If we assume I have 
that same code you just posted, how would I go about using it through the 
Racket FFI? I know I can define a _my_c_struct-pointer, but how do I make a 
pointer to that pointer to pass to the C function?

On Jun 10, 2012, at 5:42 AM, Joshua Ewulo <[email protected]> wrote:

> Say you have a struct.
> struct my_c_struct {};
> my_c_struct *ptr = 0; // uninitialised pointer
> 
> You need to prototype the function with a pointer to a pointer
> void my_func(my_c_struct **pptr);
> 
> void my_func(my_c_struct **pptr)
> {
>     *ptr = new my_c_struct;
>     if (!*ptr) printf ("error no memory\n");
>     else printf ("aye memory\n");
> }
> 
> 
> 
> 
> 
> 
> On 10 June 2012 01:57, Vince Kuyatt <[email protected]> wrote:
> I need to be able to define a variable which is an un-initialized pointer to 
> a C struct, then pass a reference to that pointer to a C function. How would 
> I go about doing this? 
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users
> 
> 
____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to