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 nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id EA65BBB81 for ; Mon, 3 Apr 2006 11:33:00 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k339X0dm013431 for ; Mon, 3 Apr 2006 11:33:00 +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 LAA09280 for ; Mon, 3 Apr 2006 11:33:00 +0200 (MET DST) Received: from mx1.mail.ru (mx1.mail.ru [194.67.23.121]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k339WxYD013427 for ; Mon, 3 Apr 2006 11:32:59 +0200 Received: from [80.190.241.118] (port=58363 helo=bely) by mx1.mail.ru with asmtp id 1FQLQa-0009ad-00 for caml-list@inria.fr; Mon, 03 Apr 2006 13:32:53 +0400 Received: from localhost (HELO BELY) [127.0.0.1] by bely (0.0.0.2) with ESMTP (Classic Hamster Vr. 2.0 Build 2.0.0.1) ; Mon, 03 Apr 2006 13:24:24 +0400 X-Comment-To: =?iso-8859-1?Q?Li-Thiao-T=E9_S=E9bastien?= To: caml-list@inria.fr Subject: Re: [Caml-list] Documentation request: allocation of bigarrays in C References: <442D3667.90904@crans.org> <442E5314.9080804@crans.org> <44303A0A.9020003@crans.org> From: Dmitry Bely Date: Mon, 03 Apr 2006 13:24:24 +0400 In-Reply-To: <44303A0A.9020003@crans.org> (Li-Thiao-T's message of "Sun, 02 Apr 2006 22:54:34 +0200") Message-ID: User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.5 (windows-nt) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Posting-Agent: Hamster/2.0.0.1 X-Miltered: at nez-perce with ID 4430EBCC.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 4430EBCB.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; bigarrays:01 bigarrays:01 parsing:01 bigarray:01 genarray:01 parser:01 alloc:01 bigarray:01 alloc:01 malloc:01 bug:01 ocaml:01 heap:01 heap:01 caml-list:01 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 Li-Thiao-T=E9 S=E9bastien writes: > I do not know in advance the size of the multiple bigarrays to > allocate. This is determined by parsing the file. To speed up the > process, the file is parsed on the C side, which is why I want to do > GC-friendly memory allocation directly from C. > I do not believe that calling Bigarray.Genarray.create within a C > parser is a nice way to do things, especially when there is the > opportunity to use alloc_bigarray_xxx to allocate memory. OK, probably the NULL case from alloc_bigarray() comment /* [alloc_bigarray] will allocate a new bigarray object in the heap. If [data] is NULL, the memory for the contents is also allocated (with [malloc]) by [alloc_bigarray]. [data] cannot point into the Caml heap. [dim] may point into an object in the Caml heap. */ should also be mentioned in the docs. If you believe it's necessary, file the bug report at http://caml.inria.fr/mantis. > NB: I do not return a single bigarray to ocaml, but a list of bigarrays. It's hard to imagine when it's really needed, but probably you have ample grounds for such design. - Dmitry Bely