Re: Need help: O'Caml C Interface

Jerome Vouillon (vouillon@clipper.ens.fr)
Tue, 24 Sep 1996 19:11:01 +0200 (MET DST)

Date: Tue, 24 Sep 1996 19:11:01 +0200 (MET DST)
From: Jerome Vouillon <vouillon@clipper.ens.fr>
Subject: Re: Need help: O'Caml C Interface
To: Juan Jose Quintela Carreira <quintela@finisterrae.dc.fi.udc.es>
In-Reply-To: <9609241445.AA10783@dc.fi.udc.es>
Message-Id: <Pine.3.89.9609241815.A28700-0100000@vedette>

> If you changes the lines:
> >
> > value ocaml_getCharWidth(value code)
> > {
> > double x, y;
> > Push_roots(r,1);
> >
> > r[0] = alloc_tuple(2);
> > getCharWidth(Int_val(code),&x,&y);
> - Store_double_val(Field(r[0],0),x);
> + modify(&Field(r[0],0),copy_double(x); /* Field(r[0],0)=copy_double(x)*/
> - Store_double_val(Field(r[0],1),y);
> + modify(&Field(r[0],1),copy_double(y); /* Field(r[0],1)=copy_double(y)*/
> > Pop_roots();
> > return r[0];
> > }
> >
>
> The coment sentences also work in this example, but the former work always,

Well, actually neither are correct, as copy_double allocate some memory.
Thus, the tuple should have been filled with dummy values prior to the
first call to copy_double, and one cannot use `Field(..) = ..'.

Jerome