From: Richard Jones <rich@annexia.org>
To: caml-list@inria.fr
Subject: Copying strings which may contain NUL chars
Date: Sat, 29 Jan 2005 12:00:10 +0000 [thread overview]
Message-ID: <20050129120009.GA7721@furbychan.cocan.org> (raw)
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);
}
--
Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology - http://merjis.com
Team Notepad - intranets and extranets for business - http://team-notepad.com
next reply other threads:[~2005-01-29 12:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-29 12:00 Richard Jones [this message]
2005-01-31 16:03 ` [Caml-list] " Damien Doligez
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=20050129120009.GA7721@furbychan.cocan.org \
--to=rich@annexia.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