Re: Calling C from OCaml, GC problems

From: Juan J. Quintela (quintela@fi.udc.es)
Date: Fri Feb 18 2000 - 11:48:43 MET

  • Next message: Gerd Stolpmann: "Loading libraries"

    > 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
    



    This archive was generated by hypermail 2b29 : Mon Feb 21 2000 - 18:15:44 MET