LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

IntensityPlot-Problem

using an intensity-plot I have a creazy problem. wanted dynamically build the colorMap for the intensityPlots just when needed. but just this does not run. if I build the colorMap-Entries in static way all runs fine. but in dynamical way I always get error -125 "color is invalid". some lines for illustration attached. any idea?

//Some statics for testing
ColorMapEntry map[2];

//Build ColorMap
for(ix=0; ix<2; ix++)
{
//pPlot is a Pointer to a structure having all the
//things needed for the job - not interesting
//1. Statically - runs ok
(*pPlot).pColorMap[ix]=&map[ix];
//2. Dynamically - doesnt run
//(*pPlot).pColorMap[ix]= malloc(sizeof(ColorMapEntry));
(*pPlot).pColorMap[ix]->color=VAL_GREEN+ix;
(*pPlot).pColorMap[ix]->dataValue.valUChar=2+ix;
}

//if doing the job dynamically - "plot->plotHandle" will be "-125" Why this ???
pPlot->plotHandle = PlotIntensity (pHandle, ctrlHandle, ucPlotDataPtr, PLOT_CH_NUMBER, PLOT_CH_NUMBER, VAL_UNSIGNED_CHAR,pPlot->pColorMap[0],VAL_GREEN,2, 0, 0);

best regards

Simon
0 Kudos
Message 1 of 2
(3,093 Views)

If you are running under Debug, then your map[2] array will be initialised to 0, whereas the malloc() operation will give you memory initialised to garbage. Depending on the details of your structures/unions, you may be inadvertantly relying on, for example, high-order bytes of a word being 0 while you assign just the low order byte and then use the whole word as a parameter. Try using calloc() in place of malloc(), to initialise the dynamic memory to 0 as well.

JR

Message Edited by jr_2005 on 07-31-2006 05:27 PM

0 Kudos
Message 2 of 2
(3,085 Views)