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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 11D54BBAF for ; Wed, 25 Aug 2010 17:21:16 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ap0BAI7RdEzZSMDdi2dsb2JhbACTJY0gFQEBAQoLCgcPBR+8QIU3BA X-IronPort-AV: E=Sophos;i="4.56,269,1280700000"; d="scan'208";a="68207295" Received: from fmmailgate01.web.de ([217.72.192.221]) by mail4-smtp-sop.national.inria.fr with ESMTP; 25 Aug 2010 17:21:15 +0200 Received: from smtp01.web.de ( [172.20.0.243]) by fmmailgate01.web.de (Postfix) with ESMTP id 10075166A5EF4 for ; Wed, 25 Aug 2010 17:21:15 +0200 (CEST) Received: from [78.43.204.177] (helo=frosties.localdomain) by smtp01.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #24) id 1OoHms-0005jO-00 for caml-list@yquem.inria.fr; Wed, 25 Aug 2010 17:21:15 +0200 Received: from mrvn by frosties.localdomain with local (Exim 4.72) (envelope-from ) id 1OoHms-0008FA-Fe for caml-list@yquem.inria.fr; Wed, 25 Aug 2010 17:21:14 +0200 From: Goswin von Brederlow To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] caml_copy_string References: <201008231409.06024.monnier.florent@gmail.com> Date: Wed, 25 Aug 2010 17:21:14 +0200 In-Reply-To: <201008231409.06024.monnier.florent@gmail.com> (Florent Monnier's message of "Mon, 23 Aug 2010 14:09:05 +0200") Message-ID: <878w3ubtw5.fsf@frosties.localdomain> User-Agent: Gnus/5.110009 (No Gnus v0.9) XEmacs/21.4.22 (linux, no MULE) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Sender: goswin-v-b@web.de X-Sender: goswin-v-b@web.de X-Provags-ID: V01U2FsdGVkX1/wuyZphb7Wd82XTnAYyp8WPpR0RN2rvqyCac3w CNRwJ/AKLZ+5D/HjiQYLNABdqbYFO7kzi1tzahrFnHNRrlF138 eMSAjtq7w= X-Spam: no; 0.00; ocaml:01 ocaml:01 buffer:01 allocations:01 buffer:01 bigarray:01 bigarray:01 28,:98 mfg:98 heap:01 caml-list:01 writes:01 data:02 caml:02 caml:02 Florent Monnier writes: > Le dimanche 22 août 2010 01:30:28, Jeffrey Barber a écrit : >> Is there a way to get a string from C to OCaml without the caml_copy_string >> function, or is there a version that doesn't copy the string? > > an alternative method is to provide a string from ocaml to c then c fills this > buffer, then you can save allocations by reusing the same buffer, see: Even better as buffer, for when you have a C function that takes a while and should use caml_enter/leave_blocking_section(), is a Bigarray. The data part of a bigarray is allocated outside the GC heap and remains fixed. MfG Goswin