Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Data_custom_val()
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Nicolas Cannasse <warplayer@f...>
Subject: Re: [Caml-list] Data_custom_val()
> CAMLprim value ocaml_foo_record(value unit)
> {
>   CAMLparam1(unit);
>   value block;
>   block = alloc_custom(&ops, sizeof(char *), sizeof(char *), 100);
> #if 0
>   Field(block, 1) = (value)malloc(1024*1024);
> #else
>  *((char *)Data_custom_val(block)) = *((char *)malloc(1024*1024));

Sorry I replied a little too fast.
Looks like this last line is using one more indirection.

 *((char **)Data_custom_val(block)) = (char *)malloc(1024*1024);
Looks better.

Nicolas Cannasse

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners