hello everyone, i'm using CVI 2012 SP1 and i have this problem.
i have a function that load panel and assign an unsigned char array as callback data to the panel and to the timer.
when i use the array with the timer everything seems ok, when i close the panel and make a memset it's seem that the function works but after i find the value in the array.
can you check my code?
i have deleted not necessary code.
p.s. i know i don't need to memset because when i close the panel and the function quit the variable will be deleted from memory but i didn't understand why the callback with memset seems to work but if i check the memory is not reset.
void LoadAlarmPage(void) { int panelAHandle = {0}; unsigned char byte_all[16] = {0}; panelAHandle = LoadPanel(0, "allarmi.uir", PANEL_ALL); if (panelAHandle < 0) { return; } SetCtrlAttribute (panelAHandle, PANEL_ALL_TIMER, ATTR_CALLBACK_DATA, byte_all); SetPanelAttribute (panelAHandle, ATTR_CALLBACK_DATA, byte_all); if (InstallPopup(panelAHandle) == 0) { RunUserInterface(); RemovePopup(0); } DiscardPanel(panelAHandle); return; }
int CVICALLBACK PanelAlarmCallback(int panel, int event, void *callbackData, int eventData1, int eventData2) { unsigned char *byte_all = callbackData; switch(event) { case EVENT_CLOSE: memset (byte_all, 0, 16); QuitUserInterface(0); break; } return 0; }
int CVICALLBACK Gest_All(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { unsigned char *byte_all = callbackData; union S_DB10 *DB10 = {0}; int i = {0}; switch (event) { case EVENT_TIMER_TICK: switch (control) { case PANEL_ALL_TIMER: // DB10 = GetPointerToDB10(); if(memcmp(DB10->byte_all, byte_all, 16) != 0) { memcpy (byte_all, DB10->byte_all, 16);
} ReleasePointerToDB10(); break; } break; } return 0; }