Boehm garbage collector for C

is anybody out there experienced with the boehm gc?

this is a very simple function:

 int fn1(){ 
    int *p = (int *) GC_MALLOC(sizeof(int *));   
    return 0; 
}

after leaving fn1() gc should free p.

***

now another example:

int* fn2(){  
    int* p= (int *) GC_MALLOC(sizeof(int *));
    return p;
 }

after leaving fn2() gc should not free p.

int main (...){
     int* n = fn1;
     *n+=2;
     fn3(n);
     ...
}

my question is: does something like that work or is there any gc related function/macro for assigning a pointer to a pointer allocated by gc?

Sound interesting enough. Thanks for the pointer. I will make sure this pointer will not leave me when I leave this function.

1 Like