05-12-2011 12:23 PM
I have a shared library with a function whose header is:
void __cdecl nextevent(double Input[], int32_t len);
When called it sends the values in Input[] to the control Input:
This vi is compiled to a DLL which uses the header above.
My question now is: Which of these operations is the correct one:
1. The Input control is a reference to the array Input[], no values are copied.
2. The values in the array Input[] are copied to the control Input, the local copy is used by the vi, then the values in the local copy are removed/deallocated.
It seems reasonable to me that 1 is the correct one, but I can't be sure, and I can't think of any way to check it.
Solved! Go to Solution.
05-27-2011 07:45 AM
For this particular case option 2 is valid. The reason is that LabVIEW arrays are not just pointers to a memory location but handles. And there is no legal way to create valid LabVIEW handles from an C runtime allocated memory pointer. So LabVIEW converts the incoming array pointer into a handle which is basically nothing else than allocating the handle with a size large enough to hold all array data, and then copies the data from the array pointer into this handle. After the call, the handle is properly deallocated.