Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Binding problem.
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-04-30 (21:20)
From: David Brown <caml-list@d...>
Subject: Re: [Caml-list] Binding problem, fixed.
On Tue, Apr 29, 2003 at 11:06:02PM -0700, David Brown wrote:

> I'm trying to create a binding to sqlite.  It seems to work most of the
> time, except occasionally it makes the ocaml GC segv.

I found a pair of problems.  The first was using: I used Field (var, n)
= ... where I needed to use Store_field.

To, make sure I understand this.  I am allowed to use Field (var, n) =
as long as I can guarantee that 'var' is not shared.  In other words, it
was allocated with alloc_small (or equivalent), and no other allocations
have taken place.  If I'm doing other allocations (say to come up with
the values to store), then I need to make sure that modify gets called.

The second was to use

        Store_field (var, n, copy_string (...));

The string needs to be put in a variable and assigned in a separate
step.  Otherwise 'var' might get moved by the garbage collector, and C
doesn't guarantee anything about evaluation order.

I put the working versions of the binding files on the web server if
anyone wants to look at them.  They still need some cleaning up.



To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: