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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 1E92CBBAF for ; Tue, 18 May 2010 08:57:56 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AksCAN7W8UvZSMDqkWdsb2JhbACdeRUBAQEBCQsKBxEDH7wGgm4IghoE X-IronPort-AV: E=Sophos;i="4.53,253,1272837600"; d="scan'208";a="62990905" Received: from fmmailgate03.web.de ([217.72.192.234]) by mail4-smtp-sop.national.inria.fr with ESMTP; 18 May 2010 08:57:55 +0200 Received: from smtp06.web.de ( [172.20.5.172]) by fmmailgate03.web.de (Postfix) with ESMTP id 28AD1150A88BE; Tue, 18 May 2010 08:57:55 +0200 (CEST) Received: from [78.43.204.177] (helo=frosties.localdomain) by smtp06.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #4) id 1OEGkU-0003ll-00; Tue, 18 May 2010 08:57:55 +0200 Received: from mrvn by frosties.localdomain with local (Exim 4.71) (envelope-from ) id 1OEGka-0006b7-7L; Tue, 18 May 2010 08:58:00 +0200 From: Goswin von Brederlow To: lyn HONG Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] What should the "size" in "caml_alloc_custom" be? References: Date: Tue, 18 May 2010 08:58:00 +0200 In-Reply-To: (lyn HONG's message of "Mon, 17 May 2010 14:00:28 -0400") Message-ID: <87aarxitmv.fsf@frosties.localdomain> User-Agent: Gnus/5.110009 (No Gnus v0.9) XEmacs/21.4.22 (linux, no MULE) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Sender: goswin-v-b@web.de X-Sender: goswin-v-b@web.de X-Provags-ID: V01U2FsdGVkX18f5/STdP+rFoGSnjbb15c7WlAhNfKcWRylyQ6i ssmdv6Zr3ArDhJppqyN8DFOqYVw8nsT7bDA8yoeXH2ClgcNFnk W/yrqAPzY= X-Spam: no; 0.00; alloc:01 allocating:01 ocaml:01 alloc:01 pointer:01 pointer:01 ocaml:01 malloc:01 mfg:98 heap:01 caml-list:01 pair:01 writes:01 caml:02 caml:02 lyn HONG writes: > Hi all, > > I have a question about "allocating custom blocks" in "iterfacing C with object > Ocaml". when we call function "caml_alloc_custom(ops, size, used, max)" in the > C side, if the structure we want to allocate has a pointer, is the "size"  > going to be size of the structure itself only, or should we also include the > memory block that pointer points to? > > Thanks, > Lin The size is the number of ocaml words in the structure itself. The pointer then points outside the ocaml heap to some C memory allocated by malloc(). You should account for that size in the used/max pair. MfG Goswin