Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: Need help: O'Caml C Interface
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jerome Vouillon <vouillon@c...>
Subject: Re: Need help: O'Caml C Interface


> 	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