From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 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 B685EBBCA for ; Fri, 15 Feb 2008 20:02:49 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAO9wtUfAXQInh2dsb2JhbACQTgEBAQgKKZ1Q X-IronPort-AV: E=Sophos;i="4.25,359,1199660400"; d="scan'208";a="22684240" Received: from concorde.inria.fr ([192.93.2.39]) by mail4-smtp-sop.national.inria.fr with ESMTP; 15 Feb 2008 20:02:49 +0100 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id m1FJ2iP7032146 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Fri, 15 Feb 2008 20:02:48 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAALhwtUdA6bjikGdsb2JhbACQTgEBAQEHBAQJChEHnU4 X-IronPort-AV: E=Sophos;i="4.25,359,1199660400"; d="scan'208";a="8139698" Received: from wr-out-0506.google.com ([64.233.184.226]) by mail1-smtp-roc.national.inria.fr with ESMTP; 15 Feb 2008 20:02:44 +0100 Received: by wr-out-0506.google.com with SMTP id c57so777124wra.9 for ; Fri, 15 Feb 2008 11:02:43 -0800 (PST) Received: by 10.142.245.10 with SMTP id s10mr2563508wfh.156.1203102162088; Fri, 15 Feb 2008 11:02:42 -0800 (PST) Received: by 10.142.173.18 with HTTP; Fri, 15 Feb 2008 11:02:42 -0800 (PST) Message-ID: <3a360f590802151102s27f9a2f6i7d9877daa7c67249@mail.gmail.com> Date: Fri, 15 Feb 2008 14:02:42 -0500 From: "Hezekiah M. Carty" Sender: hcarty@mulethief.com To: caml-list Subject: camlidl and 2D arrays with the [out] attribute MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Google-Sender-Auth: f844410e0ef85f37 X-Miltered: at concorde with ID 47B5E1D4.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlidl:01 arrays:01 camlidl:01 allocating:01 malloc:01 sizeof:01 allocates:01 hand-written:01 bindings:01 mlname:01 rectangular:98 int:01 int:01 data:02 argument:02 I am attempting to use camlidl to wrap a function with the following C prototype portion (see [1] for the full prototype): ... void c_plriddata( ... int nptsx, ... int nptsy, [out, size_is(nptsx,nptsy)] double ** zg ...); There is a lot more in the full prototype [1], but these are the important bits for this question. In this form, the 2D zg array is not allocated as I would have expected. Rather than allocating a rectangular nptsx by nptsy array, the generated C is: zg = camlidl_malloc(nptsx * sizeof(double *), _ctx); This is then passed in to the c_plgriddata function as-is, which in turn causes a segmentation fault as c_plgriddata expects that zg has already been fully allocated as a two dimensional double array. If I add the "in" attribute to the zg argument in the annotated C prototype, then camlidl fully allocates the required space. I do not want to have to do this, as the zg array is only needed as an output from this function, not an input. If there is no fix/solution to my problem with camlidl then I can write the binding for this particular function by hand. I would prefer to keep the amount of hand-written C bindings I need to maintain to a minimum. camlidl has made wrapping almost all of the rest of this library (PLplot) very straightforward. Sincerely, Hez [1] - Full function prototype: [mlname(plgriddata)] void c_plgriddata ( [in, size_is(npts)] double * x, [in, size_is(npts)] double * y, [in, size_is(npts)] double * z, int npts, [in, size_is(nptsx)] double * xg, int nptsx, [in, size_is(nptsy)] double * yg, int nptsy, [out, size_is(nptsx,nptsy)] double ** zg, int type, double data); -- Hezekiah M. Carty Graduate Research Assistant University of Maryland Department of Atmospheric and Oceanic Science