From: Robert Roessler <robertr@rftp.com>
To: Jonathan Roewen <jonathan.roewen@gmail.com>
Cc: Caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] caml_copy_string
Date: Fri, 28 Oct 2005 17:32:07 -0700 [thread overview]
Message-ID: <4362C307.3010809@rftp.com> (raw)
In-Reply-To: <ad8cfe7e0510281724h3c180efbmdf0711ebcc3abfe0@mail.gmail.com>
Jonathan Roewen wrote:
> I notice than caml_copy_string only works with null terminated
> C-strings. What is the alternative way to copy a random amount of
> char* data that contains embedded nulls into an ocaml string (knowing
> the length of the data)?
>
> Also, out of curiosity: does caml_copy_string reference the string
> itself, or does it make a full copy of it (no sharing)? IE, does
> modification of the C-string affect the ocaml string?
Use caml_alloc_string(n) to create an *uninitialized* Caml string n
bytes in length. At least one zero byte will be provided by the Caml
runtime at the end (possibly more, based on alignment issues).
caml_copy_string is a full physical copy (terminated by the first
encountered zero byte) of the supplied string - there is no "sharing".
Robert Roessler
robertr@rftp.com
http://www.rftp.com
next prev parent reply other threads:[~2005-10-29 0:34 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-29 0:24 Jonathan Roewen
2005-10-29 0:32 ` Robert Roessler [this message]
2010-08-21 23:30 caml_copy_string Jeffrey Barber
2010-08-21 23:42 ` [Caml-list] caml_copy_string Romain Beauxis
2010-08-21 23:46 ` Mathias Kende
2010-08-22 17:16 ` Till Varoquaux
2010-08-23 0:42 ` Till Varoquaux
2010-08-23 1:02 ` Jeffrey Barber
2010-08-23 12:09 ` Florent Monnier
2010-08-23 12:59 ` Stéphane Glondu
2010-08-23 13:46 ` Florent Monnier
2010-08-23 20:24 ` Romain Beauxis
2010-08-24 14:21 ` Florent Monnier
2010-08-24 14:52 ` Till Varoquaux
2010-08-24 15:22 ` Anil Madhavapeddy
2010-08-24 15:35 ` Romain Beauxis
2010-08-25 19:16 ` Florent Monnier
2010-08-25 19:33 ` Romain Beauxis
2010-08-25 15:21 ` Goswin von Brederlow
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=4362C307.3010809@rftp.com \
--to=robertr@rftp.com \
--cc=caml-list@inria.fr \
--cc=jonathan.roewen@gmail.com \
/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