From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id CC64ABB9A for ; Sat, 29 Oct 2005 02:34:16 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j9T0YG8K013871 for ; Sat, 29 Oct 2005 02:34:16 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id CAA31575 for ; Sat, 29 Oct 2005 02:34:15 +0200 (MET DST) Received: from smtp107.sbc.mail.mud.yahoo.com (smtp107.sbc.mail.mud.yahoo.com [68.142.198.206]) by nez-perce.inria.fr (8.13.0/8.13.0) with SMTP id j9T0YEMV024673 for ; Sat, 29 Oct 2005 02:34:15 +0200 Received: (qmail 59149 invoked from network); 29 Oct 2005 00:34:14 -0000 Received: from unknown (HELO ?192.168.1.100?) (rftp@pacbell.net@63.194.18.166 with plain) by smtp107.sbc.mail.mud.yahoo.com with SMTP; 29 Oct 2005 00:34:13 -0000 Message-ID: <4362C307.3010809@rftp.com> Date: Fri, 28 Oct 2005 17:32:07 -0700 From: Robert Roessler Organization: Robert's High-performance Software User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20051026 SeaMonkey/1.1a MIME-Version: 1.0 To: Jonathan Roewen Cc: Caml-list Subject: Re: [Caml-list] caml_copy_string References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 4362C388.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 4362C386.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 char:01 ocaml:01 ocaml:01 alloc:01 byte:01 runtime:01 alignment:01 byte:01 wrote:01 data:02 data:02 caml:02 caml:02 string:03 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 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