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 concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 792FDBB84 for ; Mon, 24 Jul 2006 09:50:34 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k6O7oYns025187 for ; Mon, 24 Jul 2006 09:50:34 +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 JAA25662 for ; Mon, 24 Jul 2006 09:50:33 +0200 (MET DST) Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.181]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k6O7oWJs027210 for ; Mon, 24 Jul 2006 09:50:33 +0200 Received: by py-out-1112.google.com with SMTP id f25so2756392pyf for ; Mon, 24 Jul 2006 00:50:32 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:to:subject:x-mailer:from:message-id:mime-version:content-type:content-transfer-encoding:date; b=j52IUKknvw1PvwvcOK2O9pMw7XadJZUwryFhSHzlflZmBttTgvikg7tOxQ45SBjfRnwYqn+pWLhRc0joSYj+FCk+l21Ej3RjHm+SqoK6gbX/Rgc+7EKJ/I08kH0VU/FfVUve9dGp3OG/Ttg9RofJo6V5pHDKdS+3BGZOqTAU+9c= Received: by 10.35.105.18 with SMTP id h18mr7096670pym; Mon, 24 Jul 2006 00:50:32 -0700 (PDT) Received: from beos ( [203.100.216.234]) by mx.gmail.com with ESMTP id b43sm77933pyb.2006.07.24.00.50.30; Mon, 24 Jul 2006 00:50:32 -0700 (PDT) To: caml-list@inria.fr Subject: [Caml-list] help with caml_stat_alloc X-Mailer: BeMail - Mail Daemon Replacement 3.0.2 Final From: "Jonathan Roewen" Message-Id: <73347253780-BeMail@beos> Mime-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Date: Mon, 24 Jul 2006 00:50:32 -0700 (PDT) X-j-chkmail-Score: MSGID : 44C47BC8.000 on nez-perce : j-chkmail score : X : 0/20 1 X-Miltered: at concorde with ID 44C47BCA.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 44C47BC8.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 ocaml:01 icfp:01 heap:01 caml-list:01 int:01 int:01 caml:02 caml:02 external:02 external:02 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 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); } Also, my interface in ocaml is: external alloc : int32 -> int32 = "icfp_alloc" external free : int32 -> unit = "icfp_free" external get : int32 -> int32 -> int32 = "icfp_get" external set : int32 -> int32 -> int32 -> unit = "icfp_set" external copy : int32 -> int32 = "icfp_copy" Some guidance would be much appreciated, Jonathan