LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DSNewHandle fails with 2-D handle

All;

The following bit of code (StringRowAdd) mem-faults in a LV-called DLL, the other code (StringAdd) works fine. Can a programming god figure out what I'm doing wrong here?

...Dan

void StringRowAdd(TD4Hdl in_array, char *string[], int cols)
{
int i=0, j=0;
j = (*in_array)->dimSizes[0] * (*in_array)->dimSizes[1];
(*in_array)->dimSizes[0]++; if (j == 0)(*in_array)->dimSizes[1] = cols;

for (i=0; i
(*in_array)->String[j + i] = (LStrHandle)(DSNewHandle(sizeof(int32) + strlen(string[i])*sizeof(char)));
/* (*(*in_array)->String[j + i])->cnt=strlen(string[i]);
strcpy((*(*in_array)->String[j + i])->str, string[i]); */}
}

void StringAdd(TD2Hdl in_array, char *string)
{
int i, j;

j = (*in_array)->dimSize++;
(*in_array)->String[j] = (LStrHandle)(DSNewHandle(sizeof(int32) + strlen(string)*sizeof(char)));

(*(*in_array)->String[j])->cnt=strlen(string);
strcpy((*(*in_array)->String[j])->str, string);
}

typedef struct {
int32 dimSize;
LStrHandle String[1];
} TD2;
typedef TD2 **TD2Hdl;

typedef struct {
int32 dimSizes[2];
LStrHandle String[1];
} TD4;
typedef TD4 **TD4Hdl;
0 Kudos
Message 1 of 2
(2,648 Views)
Hello dgholstein,

I could not see any glaring errors in the code snippet you posted. You may want to look closer at your for loop and confirm that you are not iterating out of your String array's bounds.

It may also be helpful to run your compilers debugger while calling the DLL in LabVIEW and watch the allocations in real time.

Good luck with the development.

Regards,

Matt F
0 Kudos
Message 2 of 2
(2,479 Views)