05-26-2010 09:11 PM
Here is some code for a simplified DLL that I'm using as a test case. LabVIEW preallocates memory by initializing arrays of 19 and 21 elements, but the output of the function is an array of 38 and an array of 42. Why does it do this?
_declspec(dllexport) int split_array(unsigned char* array_in, unsigned char* split1, unsigned char* split2);
int split_array(unsigned char* array_in, unsigned char* split1, unsigned char* split2)
{
int i;for (i = 0; i < 19; i++)
{
split1[i] = array_in[i];
}
for (i = 19; i < 40; i++)
{
split2[(i-19)] = array_in[i];
}
return 0;
}
Solved! Go to Solution.
05-27-2010 05:09 AM
Can you show your LV code to go with this?
Shane
05-27-2010 09:41 AM
Here is a screenshot:
sizeof array = 40
sizeof split1 = 38
sizeof split2 = 42
05-27-2010 10:44 AM
05-27-2010 10:53 AM
05-27-2010 11:09 AM
Calling convention:
and Sub VI:
05-27-2010 11:11 AM - edited 05-27-2010 11:12 AM
Just post the VIs and the DLL so that we can see what's going on.
05-27-2010 12:22 PM
05-27-2010 12:24 PM - edited 05-27-2010 12:26 PM
05-27-2010 01:42 PM
Well, I think the fact that in the configuration for the DLL you set the minimum size of split1 to be 38 and the minimum size of split2 to be 42 might be a clue as to why your arrays are... 38 and 42.
If you read the documentation on that setting it says:
Indicates the minimum size of a 1D array and allocates the correct amount of memory. You can enter a numeric value, or, if you configure an integer parameter in the Parameters list, you can select the parameter from the pull-down menu. The default is none. This option is available only for array data pointers. If you pass in an array that is smaller than the minimum size, LabVIEW enlarges the size of the array to the minimum. If you pass in an array that is bigger than the minimum, the array retains the larger size.