[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | David Brown <caml-list@d...> |
| Subject: | Re: [Caml-list] Binding problem. |
On Wed, Apr 30, 2003 at 09:41:19AM +0400, Nickolay Kolchin-Semyonov wrote:
> Always use CAMLparam with true arguments number!
There's no real point, since some of the arguments are C heap pointers,
so they're never going to move. It also isn't needed if the arguments
are only used before the first allocation.
> You have a bug in
> caml_sqlite_compile (value db, value query)
>
> strcpy (String_val (tmp), tail);
>
> Don't do that. Instead work with char pointers and convert to Ocaml types only
> at function end. I.e. (I just fixed code that don't like, without
> understanding your algorithms)
Actually, that part works just fine, at least the string manipulation.
The example you give needs to change the
Field (pair, 1) = copy_string (tmp);
into a
Store_field (pair, 1, copy_string (tmp));
since the copy_string can call the GC, and could move the pair into the
shared heap. I learned this because I just figured out what was wrong
with the binding :-)
The code I have there is kind of gross, but will always work, since
sqlite always will return a tail value that points later on. I kind of
wanted to avoid a malloc and free to copy a value that in normal cases
will never be used.
Thanks for looking at it,
Dave
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners