Version française
Home     About     Download     Resources     Contact us    
Browse thread
Calling C from OCaml, GC problems
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Juan J. Quintela <quintela@f...>
Subject: Re: Calling C from OCaml, GC problems

> value mlbdd_alloc_manager(MANAGER m) {
>        CAMLparam0();
>        CAMLlocal1 (result);  

>        bdd_overflow_closure(m, mlbdd_overflow, NULL);
>        result = alloc_final(Size_ml_manager, mlbdd_free_manager, 0, 1);
>        Manager_store_pointer(result, (value)m);
>        PRINT_DEBUG("Alloc manager");
>        CAMLreturn result;
>}

I think you need to protect m with 
CAMLparam1(m);
otherwise in the allocation alloc_final, the garbage collector can be
called and the address to m change.

I hope this help.

Later, Juan.

-- 
In theory, practice and theory are the same, but in practice they 
are different -- Larry McVoy