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

Home » Public Forums » archive » Dynamic arrays in structs: re-allocation problem
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Dynamic arrays in structs: re-allocation problem [message #70028] Tue, 09 March 2010 07:59
franzpx125 is currently offline  franzpx125
Messages: 6
Registered: September 2008
Junior Member
Hi!,

I have troubles with dynamic arrays in structs. The method I use
(following N. Wade suggestion) is to define the struct tags in this
way:

static IDL_MEMINT stats_width_dims[IDL_MAX_ARRAY_DIM];

IDL_STRUCT_TAG_DEF stats_tags[] = {
{ "WIDTH", stats_width_dims, (void *) IDL_TYP_DOUBLE },
{ 0 }
};

Next I populate the dims arrays which define the size of the dynamic
arrays and make a structure with IDL_MakeStruct:

stats_width_dims[0] = 1;
stats_width_dims[1] = stats->counter;
s = IDL_MakeStruct("STATS", stats_tags);

Finally I create a temp structure using IDL_MakeTempStruct:

tmp_dims[0] = 1;
s_data = (char *)IDL_MakeTempStruct(s, 1, tmp_dims, &idl_out_struct,
TRUE);

This temporary structure is returned to IDL after populating it:

offset = IDL_StructTagInfoByName(s, "WIDTH", IDL_MSG_LONGJMP, NULL);
d_tmp_ptr = (double *)(s_data + offset);
for ( i = 0; i < stats->Node_Counter; i++)
*(d_tmp_ptr++) = stats->width[i];

return idl_out_struct;

First time the code is executed, everything works properly. In the
second call I'm not able to set the dynamic array with the new
dimension and, obviously, if the new dimension is greater than the
previous one IDL crashes. I think that the code:

stats_width_dims[0] = 1;
stats_width_dims[1] = stats->counter;
s = IDL_MakeStruct("STATS", stats_tags);

may not be used for updating an existing struct but just for creating
a new one. I'm not able to find a valid solution... any suggestion?

Thanks,
F. Brun
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: IDL calculating elements in arrays plus there offsets
Next Topic: Reading 32-bit BMP (with an alpha channel) in IDL

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

Current Time: Fri Oct 10 06:31:18 PDT 2025

Total time taken to generate the page: 0.56266 seconds