comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Passing Structures with Pointers with Call_External
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Passing Structures with Pointers with Call_External [message #40466 is a reply to message #40461] Tue, 10 August 2004 16:12 Go to previous messageGo to previous message
Peter Mason is currently offline  Peter Mason
Messages: 145
Registered: June 1996
Senior Member
PeterOut wrote:
<...>
>
temp={Rows:long(numrows),Columns:long(numcolumns),Data:fltar r(numrows,numcol
umns)}
<...>
> The C code is as follows.
> typedef struct FloatPlane_Struct
> {
> long Rows;
> long Columns;
> float **Data;
> } FloatPlane;
<...>
> If I add
> fprintf(stderr, "fppPlanes->Data[0]=%d\n", fppPlanes->Data[0]);
> idlde crashes, presumably due to a memory write error in the C code.
> Is there any way to stop idlde crashing under such circumstances?
>
> My main question is this. Is there a way to retrieve the IDL variable
> Planes[i].Data within CFunction_cw?


The problem here is that IDL isn't creating the structure quite as you
expect. There isn't that level of indirection with DATA. Your C-side
structure should look something like this:
typedef struct FloatPlane_Struct {
int Rows;
int Columns;
float Data[n];
} FloatPlane;
Where the "n" in "Data[n]" is equal to numrows*numcolumns in your IDL-side
structure creation statement.
I think this means that you need a different approach as a C-side structure
definition is fixed at compile time ("n" must be a constant).

You might be wondering about changing your structure definition to use an
IDL "pointer" for the array? Don't even try it. The value of an IDL
pointer is like some handle index thing and bears no relation to an actual
memory address. It's meaningless to external code.

Personally, I'd suggest abandoning the use of a structure and coding a DLM
instead of CALL_EXTERNAL here. CALL_EXTERNAL is quick and easy but
sometimes it's worth going that extra distance. In a DLM you would be able
to pull out the dimensions of your DATA array (now 3-dimensional for the
frames). Also, the IDL-side work would probably be more efficient with a
straightforward array instead of arrays embedded in structures.
Alternatively, stick to CALL_EXTERNAL and pass your C function two
parameters: DATA and SIZE(DATA).

Peter Mason
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: black window on fsc_surface & fsc_surface_log?
Next Topic: Re: Combining subimage data to corresponding X and Y location

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:55:19 PDT 2025

Total time taken to generate the page: 0.00444 seconds