From: Damien Doligez <damien.doligez@inria.fr>
To: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] Copying strings which may contain NUL chars
Date: Mon, 31 Jan 2005 17:03:54 +0100 [thread overview]
Message-ID: <B4C4EC92-73A1-11D9-866D-000D9345235C@inria.fr> (raw)
In-Reply-To: <20050129120009.GA7721@furbychan.cocan.org>
On Jan 29, 2005, at 13:00, Richard Jones wrote:
> Is this code safe? hv_iterkey returns a string and a length, but the
> string may contain ASCII NUL characters, and hence I cannot use
> caml_copy_string directly.
>
> Rich.
>
> CAMLprim value
> perl4caml_hv_iterkey (value hev)
> {
> CAMLparam1 (hev);
> CAMLlocal1 (strv);
> HE *he = He_val (hev);
> I32 len;
> char *str = hv_iterkey (he, &len);
> strv = caml_alloc_string (len);
> memcpy (String_val (strv), str, len);
> CAMLreturn (strv);
> }
I don't see anything wrong with this code.
-- Damien
prev parent reply other threads:[~2005-01-31 16:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-29 12:00 Richard Jones
2005-01-31 16:03 ` Damien Doligez [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=B4C4EC92-73A1-11D9-866D-000D9345235C@inria.fr \
--to=damien.doligez@inria.fr \
--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