Once again. I have strange problem. Few days ago I have completed a rgb2hsv function which uses another function. All worked. Now I run the program and it crashes.

Code:

void bmp_rgb2hsv(BMPFILE * bmpfile, float ** f1, float ** f2)
{
uint32_t min, max;
// actual values:
min=22;
max=51;
a=0;
bmpfile->buffer[a+1]=(unsigned char) '32'; // (uninitiated)
bmpfile->buffer[a+1]=(uint32_t)((max==min?0:f2[max][min])); // crashes
}

types:

Code:

float ** MinMaxRevDelta; // MinMaxRevDelta_createArray(float ** MinMaxRevDelta, float ** SatDeltaDivMax)
float ** SatDeltaDivMax; // MinMaxRevDelta_createArray

function for initiation - (*f2)[51][22]: initiated (result is float number)

Code:

void MinMaxRevDelta_createArray(float *** f1, float *** f2){
uint32_t c; c=0;
*f1 = malloc((sizeof (uint32_t)) * 254 );
*f2 = malloc((sizeof (uint32_t)) * 254 );
unsigned short int a,b;
/*Pozor: Může některé položky budou nealokované,
protože min. nikdy není větší než max.
use: f1[max][min]; */
for (a=1; a<256; a++) // a = max
{
(*f1)[a] = malloc((sizeof (float)) * a );
(*f2)[a] = malloc((sizeof (float)) * a );
for (b=0; b<a; b++) // b = min
{
(*f1)[a][b]=1.0/(a-b); // delta: max / min
(*f2)[a][b]=(a-b)*255.5/a; // Saturation: delta / max
c++;
}
}
}

Initiation:

Code:

// Here is created array of results
MinMaxRevDelta_createArray(&MinMaxRevDelta, &SatDeltaDivMax);
// here the result for MinMaxRevDelta[51][22] and SatDeltaDivMax[51][22] is also OK floating point number
bmp_rgb2hsv(bmpfile, MinMaxRevDelta, SatDeltaDivMax);

But in the function bmp_rgb2hsv it crashes immediately. What's wrong?