Hello, I am having quite a time trying to initialize a block of memory and then hand a pointer to that memory back to LabVIEW.
1. I pass an uInt8 Array of 3000 elements (6kB) into my LabVIEW CIN
2. I prepare a block of memory in the CIN.
3. I initialize the memory by loading a static table into the block of memory
4. I WANT to move the initialized memory space into the uInt8 Array, starting at index[0]
The code below compiles, but when I run the CIN in labview, LV crashes.
What am I doing wrong?
Thank you for any help,
Victor
/* Typedefs */
typedef struct {
int32 dimSize;
uInt8 globalData2[1];
} TD1;
typedef TD1 **TD1Hdl;
typedef struct _LANGUAGE_ENTRY
{
UCHAR Language;
PVOID pTable;
} LANGUAGE_ENTRY;
extern LTABLE LANGUAGE_TABLE
void *memPtr;
extern "C"{
MgErr CINRun(TD1Hdl globalData);
}
MgErr CINRun(TD1Hdl globalData)
{
uInt16 usSize;
LANGUAGE_ENTRY MyLanguages[2];
usSize = 5576; //GlobalDataSize
memPtr = malloc( usSize );
memset( memPtr, 0, sizeof(memPtr) );
MyLanguages[0].Language = ENGLISH;
MyLanguages[0].pTable = (void*)LTABLE LANGUAGE_TABLE;
MyLanguages[1].Language = 0;
MyLanguages[1].pTable = 0;
Initialize ( MyLanguages, memPtr);
MoveBlock(memPtr, (*globalData)->globalData2, usSize);
return noErr;
}