[racket] FFI Pointer to Pointer

From: Joshua Ewulo (jewulo at gmail.com)
Date: Sun Jun 10 05:42:15 EDT 2012

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 <vince.raiken at gmail.com> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120610/3961c408/attachment-0001.html>

Posted on the users mailing list.