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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id A5853BBAF for ; Tue, 24 Aug 2010 16:52:49 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtMBAG55c0zRVdi0kGdsb2JhbACDF49ljTwIFQEBAQEJCQwHEQMfoC2IXIJPhjmJAgEBAwWBHYFTgU9zBIl4iEI X-IronPort-AV: E=Sophos;i="4.56,263,1280700000"; d="scan'208";a="66065410" Received: from mail-qy0-f180.google.com ([209.85.216.180]) by mail1-smtp-roc.national.inria.fr with ESMTP; 24 Aug 2010 16:52:49 +0200 Received: by qyk31 with SMTP id 31so6043514qyk.18 for ; Tue, 24 Aug 2010 07:52:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=NLgCMJ3+MmwwVGHGMIpTksoGXjq7T40fPcAI5lDdfdE=; b=SXyDy/BLNSn1OfdoXTxlwRRdxLGuYGJWRnl4M33aGWkD0HxQQ6/vxZ6goWrSGv8lOl y/TQLCoJ+d9L8Y3fr6c1LUlBgZN2tOADgsI+x85bKbhO/PXs/fMQUwHj6lxIP+7FV/ED tP3Vx78TEeLyeks0ikJg7yw74x/tdPPmMgA+U= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=EnbG8YteDE9deqqQpsq77AupzAF19LDKRfI8xP6nYwz5Zl003Kp1yjlSoa7pGnNC87 chaRM9omW6ItwCkdIW+xldSyi/3ieV1Ivhn3KijrleXQrhLTpCP7R+NbJBhZrXZknLVK +Y4Pko5t/j78OL58K4P5nQQgfdeO3h/1RJk/g= MIME-Version: 1.0 Received: by 10.224.28.203 with SMTP id n11mr4132507qac.42.1282661568633; Tue, 24 Aug 2010 07:52:48 -0700 (PDT) Sender: till.varoquaux@gmail.com Received: by 10.229.234.3 with HTTP; Tue, 24 Aug 2010 07:52:48 -0700 (PDT) In-Reply-To: <201008241621.02363.monnier.florent@gmail.com> References: <201008231409.06024.monnier.florent@gmail.com> <201008231524.49124.toots@rastageeks.org> <201008241621.02363.monnier.florent@gmail.com> Date: Tue, 24 Aug 2010 10:52:48 -0400 X-Google-Sender-Auth: 2ee_AuXr-iLKKTD-q2HKTtSFoSI Message-ID: Subject: Re: [Caml-list] caml_copy_string From: Till Varoquaux To: Florent Monnier Cc: caml-list@yquem.inria.fr Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; ocaml:01 buffer:01 allocations:01 buffer:01 segfault:01 iirc:01 ocaml:01 runtime:01 allocating:01 beginner's:01 bug:01 48,:98 beginners:01 wrote:01 pps:01 On Tue, Aug 24, 2010 at 10:21 AM, Florent Monnier wrote: > Le lundi 23 ao=C3=BBt 2010 22:24:48, Romain Beauxis a =C3=A9crit : >> Le lundi 23 ao=C3=BBt 2010 07:09:05, Florent Monnier a =C3=A9crit : >> > an alternative method is to provide a string from ocaml to c then c fi= lls >> > this =C2=A0buffer, then you can save allocations by reusing the same b= uffer, >> >> > see: >> This is a good idea but I would be a little bit suspicious about using >> "noalloc". Even if it works in your tests, this options is very delicate= to >> use with the Gc, and may segfault in some cases. > > could you develop? which cases? IIRC noalloc calls release the ocaml lock. This means that the runtime can run at the same time as the c call and the GC migh collect your string or move it along. Quick rule if thumb is: you are allocating your string so you should not use noalloc. Till > > > -- > Regards > Florent > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >