From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id IAA00463 for caml-redistribution; Tue, 20 Apr 1999 08:32:39 +0200 (MET DST) 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 UAA03376 for ; Mon, 19 Apr 1999 20:50:22 +0200 (MET DST) Received: from mail2.digital.com (mail2.digital.com [204.123.2.56]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id UAA14449 for ; Mon, 19 Apr 1999 20:50:21 +0200 (MET DST) From: doligez@pa.dec.com Received: from neuf.pa.dec.com (neuf.pa.dec.com [16.4.80.69]) by mail2.digital.com (8.9.2/8.9.2/WV2.0g) with SMTP id LAA19437 for ; Mon, 19 Apr 1999 11:50:19 -0700 (PDT) Received: by neuf.pa.dec.com; id AA02045; Mon, 19 Apr 1999 11:50:19 -0700 Message-Id: <199904191850.AA02045@neuf.pa.dec.com> To: caml-list@inria.fr Subject: Re: trouble with C pointers and GC In-Reply-To: Message of Mon, 19 Apr 1999 16:42:30 +0200 from Patrick Goldbronn - SYSCO <371B40D6.1760563E@cea.fr> Date: Mon, 19 Apr 1999 11:50:19 -0700 X-Mts: smtp Sender: weis >From: Patrick Goldbronn - SYSCO > adr1 = (double *) calloc(nb1,sizeof(double)); > adr2 = (int *) calloc(nb2,sizeof(int)); > >and I want to put it in a value with Final_tag : > > result = alloc_final( n , free_function , nb_elm*2 , 1 ) ; ^^^^^^^^^^^^ This doesn't look right: it will force a major GC every time, unless nb_elm == 0. >I don't know what is the value of n (n words) : A pointer value >represent 1 word or 2 ? A pointer is 1 word, and you must count the pointer to free_function, so n would be 3. >How can I store the pointers adr1 and adr2 in value result and how can I >retrieve them (with Store_field and Field ?) ? Since the pointer to free_function uses the first field, they would be at offsets 1 and 2: result = alloc_final (3, &free_function, 0, 1); Store_field (result, 1, adr1); Store_field (result, 2, adr2); And to use them: "Field (result, 1)" and "Field (result, 2)". -- Damien