From: David Brown <caml-list@davidb.org>
To: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] Binding problem.
Date: Tue, 29 Apr 2003 23:13:32 -0700 [thread overview]
Message-ID: <20030430061332.GA20759@opus.davidb.org> (raw)
In-Reply-To: <200304300941.19681.snob@metalinkltd.com>
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
next prev parent reply other threads:[~2003-04-30 6:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-30 5:28 David Brown
[not found] ` <200304300941.19681.snob@metalinkltd.com>
2003-04-30 6:13 ` David Brown [this message]
[not found] ` <20030430060602.GA20670@opus.davidb.org>
2003-04-30 21:20 ` [Caml-list] Binding problem, fixed David Brown
2003-05-01 4:49 ` [Caml-list] Binding problem David Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030430061332.GA20759@opus.davidb.org \
--to=caml-list@davidb.org \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox