[ROOT] Segentation violation with calloc

From: Aurelien COTTRANT (cottrant@lapp.in2p3.fr)
Date: Wed Jun 06 2001 - 17:25:59 MEST


Hello,

When I try this single sample of code, CINT crash with a segmentation
violation error. Without the references to massmatrn[i][j], it works
fine. I use ROOt ver 3.00/06. Could anyone help me

void test()
{

double ***massmatrn;
massmatrn =(double ***) calloc (2, sizeof(double**));

for (int i = 0; i<2 ; i=i+1)
	massmatrn[i] = (double **) calloc (2, sizeof(double*));


for (int j = 0; j<2 ; j=j+1)	
	for (int i = 0; i<2 ; i=i+1)
		massmatrn[i][j] = (double *) calloc (2, sizeof(double));


for (int i = 0; i<2 ; i=i+1)
	for (int j = 0; j<2 ; j=j+1)
		free(massmatrn[i][j]);

for (int i = 0; i<2 ; i=i+1)
	free(massmatrn[i]);
	
free(massmatrn);

}

Aurélien Cottrant



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:48 MET