From: Robert Roessler <roessler@rftp.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] c binding question
Date: Wed, 22 Feb 2006 13:37:18 -0800 [thread overview]
Message-ID: <43FCD98E.30600@rftp.com> (raw)
In-Reply-To: <200602220909.55592.micha-1@fantasymail.de>
Michael Wohlwend wrote:
> I want to make an interface to a c-lib in which some function take a char* as
> a parameter and store this paramenter in their internal variables.
> I have done this this way:
>
> I copy the ocaml-string to a new c-string and I allocated a custom block to
> store the abstract datatype of the lib together with the allocated char* for
> that string. The finalize function of that custom block releases the
> allocated memory of the string and cleans up the rest...
>
> Is this the correct way to do this?
Sounds reasonable to me - this is essentially what I do in LablPCRE.
In that case, the PCRE regcomp call fills in a local data structure
with (among other things) a pointer to malloc'ed storage... a custom
block is created, the struct is copied into it, and then a finalize
function uses PCRE's regfree call to clean up.
Robert Roessler
roessler@rftp.com
http://www.rftp.com
prev parent reply other threads:[~2006-02-22 21:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-22 8:09 Michael Wohlwend
2006-02-22 21:37 ` Robert Roessler [this message]
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=43FCD98E.30600@rftp.com \
--to=roessler@rftp.com \
--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