LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

CIN Code memory access violation

I am new to CINs and am trying something simple but get a memory access violation when the following code segment executes:

typedef struct {
int32 dimSize;
uInt8 Numeric[1];
} TD13;
typedef TD13 **TD13Hdl;

MgErr CINRun(TD13Hdl *configMsgDataIn);

MgErr CINRun( TD13Hdl *configMsgDataIn)
{

/* Insert code here */

(**configMsgDataIn)->Numeric[0] = 10;

return noErr;
}
How do I reference the array?
0 Kudos
Message 1 of 4
(2,561 Views)
> I am new to CINs and am trying something simple but get a memory
> access violation when the following code segment executes:
>
> MgErr CINRun( TD13Hdl *configMsgDataIn)
> {
>
> /* Insert code here */
>
> (**configMsgDataIn)->Numeric[0] = 10;
>
> return noErr;
> }
> How do I reference the array?

You are referencing just fine. The problem is, who has allocated the
array? If called with an array of one element, you should be fine. If
called with an array of zero elements, you will corrupt memory and
possibly crash immediately.

If you want to set the array size, look at NumericArrayResize or similar
functions.

Greg McKaskle
Message 2 of 4
(2,554 Views)
Got the same problem!!!
Can someone please tell me what is wrong with the following code?

typedef struct
{
    int32 dimSize;
    float64 Numeric[1];
} TD1;

typedef TD1 **TD1Hdl;

MgErr CINRun(TD1Hdl *Array);

MgErr CINRun(TD1Hdl *Array)
{

    int32 size = (**Array)->dimSize;

    return noErr;
}

Every single time, when trying to acces the array, Dev Studio generates the following error:
Unhandled exception in Labview.exe (LVS73.TMP) : 0XC0000005: Access Violation.


Whats the deal ??? The input array is not even empty!

Thanks...

SW used :
 
- VC++ 5.0
- Labview 7 Express - Student edition
- Windows XP Professional SP2





0 Kudos
Message 3 of 4
(2,478 Views)
It's working fine on LabVIEW 7.1.1


0 Kudos
Message 4 of 4
(2,463 Views)