LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DLL memory allocation for an array of clusters?

Hi, I am trying to make a DLL in CVI for use in Labviews. I have created an array of clusters;

typedef struct
{
uInt32 Wavelength;
float64 Power;
float64 OSNR;
} Data;

typedef struct
{
int32 dimSize;
Data peakData[1];
} DataArray;
typedef DataArray **DataArrayHandle

I'm not sure how to allocate memory for the array and cluster before writing (and passing back) the 3 data members.

I use NumericArrayResize to expand the array;

NumericArrayResize(uL, 1L, (UHandle*)&Array, (int32)1);

..then I set the dimension size;
(*Array)->dimSize = (int32)(1);

..but now I must allocate the cluster memory, and nearly everything I have tried will compile and build, but crashes Labview.
So I guess the question is..how do I allocate memory, and write to a data member?

Kindest,
Warren Crossfield
0 Kudos
Message 1 of 2
(2,939 Views)
Try using the following function instead of NumericArrayResize to expand the array:

MgErr DSSetHandleSize(h, size)

Where "h" (UHandle) is the handle you want to resize and "size" (int32) is the new size of the handle (in bytes).

Also, check the following article at ni.com:

Passing a Variety of Data Types from DLL to LabVIEW
http://zone.ni.com/devzone/devzoneweb.nsf/opendoc?openagent&443CB374ADF0B1D1862569880064C658&cat=D0A775F79852010F862567AC00583FA7

Regards;
Enrique
www.vartortech.com
0 Kudos
Message 2 of 2
(2,939 Views)