Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Documentation request: allocation of bigarrays in C
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-04-03 (09:33)
From: Dmitry Bely <dbely@m...>
Subject: Re: [Caml-list] Documentation request: allocation of bigarrays in C
Li-Thiao-Té Sébastien <> 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

> 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