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 5F5CABB84 for ; Mon, 24 Jul 2006 13:39:32 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k6OBdV2n029615 for ; Mon, 24 Jul 2006 13:39:32 +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 NAA27741 for ; Mon, 24 Jul 2006 13:39:31 +0200 (MET DST) Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.184]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k6OBdUoU029612 for ; Mon, 24 Jul 2006 13:39:31 +0200 Received: by nf-out-0910.google.com with SMTP id y38so1386067nfb for ; Mon, 24 Jul 2006 04:39:30 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=B7iOlclgz4cJ02UlJoQH3H02U3BGka/XwWhXrkb5Tnm7yt2iELKDxZ/BT6han7Xx9ckBYDoz0nqGPNiKJs5MDPgAq+Xu1zTPNgLCtnCeN1hSsgCuPQewgcXa2IE/+ZQVARSphP0WNh1JMh55JfZ1XeYHPm3Krx/7gsuaFwZh+wg= Received: by 10.48.80.20 with SMTP id d20mr3273232nfb; Mon, 24 Jul 2006 04:39:30 -0700 (PDT) Received: by 10.49.28.5 with HTTP; Mon, 24 Jul 2006 04:39:30 -0700 (PDT) Message-ID: Date: Mon, 24 Jul 2006 14:39:30 +0300 From: "Anatoly Zaretsky" To: "Jonathan Roewen" Subject: Re: [Caml-list] help with caml_stat_alloc Cc: caml-list@inria.fr In-Reply-To: <73347253780-BeMail@beos> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <73347253780-BeMail@beos> X-j-chkmail-Score: MSGID : 44C4B172.000 on nez-perce : j-chkmail score : X : 0/20 1 X-Miltered: at nez-perce with ID 44C4B173.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 44C4B172.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; alloc:01 alloc:01 camlprim:01 icfp:01 val:01 byterun:01 heap:01 wrote:01 caml-list:01 int:01 int:01 caml:02 caml:02 allocated:02 bytes:03 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=RCVD_BY_IP autolearn=disabled version=3.0.3 On 7/24/06, Jonathan Roewen wrote: > Hi, > > I'm trying to allocate some memory outside of the caml heap, and I > think caml_stat_alloc is the right function to use. Anyways, it's > generating seg-faults, so I'm hoping someone can help me fix my > implementation. > > CAMLprim value icfp_alloc(value size) { > int sz = Int32_val(size) + 1; > int *p = (int *)caml_stat_alloc(sz); > p[--sz] = sz; > /*while ( sz > 0 ) { > p[--sz] = 0; > }*/ > return caml_copy_int32(p); > } >>From byterun/memory.h: CAMLextern void * caml_stat_alloc (asize_t); /* Size in bytes. */ So p[--sz] is out of allocated region. -- Tolik