How to access data from array of pointers in LoadLibrary? Only the first is accessible

Hi.
I have in issue with LoadLibrary. I have a function that has the following prototype:
int searchDevice(DeviceData** ptr, unsigned int *size)
{
*size = 2;
(*ptr) = new (std::nothrow) DeviceData[static_cast<int>(*size)]();
for (i=0; i<*size; i++)
{
//update ptr[0 to size-1]
}
return 0; //successful
}
struct tagDeviceData
{
long long int lPortNo;
char strSerialNo[9];
};
When I perform the following in MATLAB:
loadlibrary('MyLib', 'MyLib.h')
pResultArray = libpointer('tagDeviceData');
plSize = 0;
[res, pResult, size] = calllib('MyLib','searchDevice', pResultArray, plSize)
the following is returned:
res = 0
pResult=
MATLAB struct containing:
lPortNo = //value set for index 0
strSerialNo = // value set for index 0
size = 2
I am able to access the first data (since it is the one in the returned struct) but the 2nd data is not accessible. Is there a way to access the data past the first index?
Thank you

Answers (0)

Products

Release

R2018a

Asked:

on 6 Aug 2018

Edited:

on 6 Aug 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!