LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why does this DLL double the array size?

Solved!
Go to solution

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;

}

 

 

 

0 Kudos
Message 1 of 13
(4,296 Views)

Can you show your LV code to go with this?

 

Shane

0 Kudos
Message 2 of 13
(4,269 Views)

Here is a screenshot:

 

split_dll_vi

 

sizeof array = 40

sizeof split1 = 38

sizeof split2 = 42

0 Kudos
Message 3 of 13
(4,254 Views)
Can you post the DLL calling convention with the parameters list?
0 Kudos
Message 4 of 13
(4,237 Views)
Can you also show the diagram of the subVI?
0 Kudos
Message 5 of 13
(4,230 Views)

Calling convention:

 

calling_convention.JPG 

 

 

 

and Sub VI:

 

sub_vi.JPG

0 Kudos
Message 6 of 13
(4,219 Views)

Just post the VIs and the DLL so that we can see what's going on.

Message Edited by Intaris on 05-27-2010 11:12 AM
Message 7 of 13
(4,215 Views)
 
Download All
0 Kudos
Message 8 of 13
(4,193 Views)
I couldn't post a *.dll, so split_arrayDOTdll.vi needs to be renamed.
Message Edited by steve_0001 on 05-27-2010 12:26 PM
Download All
0 Kudos
Message 9 of 13
(4,192 Views)

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.

 

 

Message 10 of 13
(4,177 Views)