LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Resizing an array of struct inside a DLL using the memory manager

Solved!
Go to solution

Hi all,

 

I dug deep inside the boards, but wasn't able to find a solution for my problem.

I'm building a dll, which does some imageprocessing and should return an array of structs to labview, with one struct for every element in the image.

As I don't know the number of elements beforehand and the limit of the number is numbers of magnitude larger then the expected one, I don't want to allocate such a huge chunk of memory prior to the dll call in labview.

In a former version I used a 2d array for the elements, where each row holds the values of every element. Here I used the NumericArrayResize-function, which worked quite well. But I have to add more sub-processes and using structs (or clusters in labview) appears to be more usefull and cleaner for me, in addition I had to cast some of the elements back and foreward a few times.

So one element-struct should hold 2 singles and 1 uint32. My question is now, how can I resize this array of struct with memory manager functions as the NumericArrayResize-functions does not suit this purpose?

(Accessing a given array of structs inside the DLL and after that reading the changed values in Labview is surprisingly easy :))

Thanks in advance

0 Kudos
Message 1 of 2
(2,611 Views)
Solution
Accepted by topic author egonuel

Well, I was able to solve it myself. I found this thread, where the first post of rolfk made me thinking. It appeared to me, that the numericarrayresize-function behaves very similar to the realloc-function of c. So I used the type unsigned int 8 (which is just one byte) and multiplied it by the number of bytes used by one struct, in my case 12 bytes (4+4+4) and then multiplied it by the number of structs (elements in the image) i have. Luckily it worked and the memory block was resized exactly as I wanted it to be. Important to note: do not forget to adjust the size element of the handle, otherwise Labview does not know about the changed size.

 

 

0 Kudos
Message 2 of 2
(2,570 Views)