Hi, I have tested the following macro with production version of ROOT on CERN/AFS. I got the same crash as the calloc version bellow. Compiled with G++ works fine. ------------------------------ cut here -------------------------- typedef double* DPtr; typedef double** DDPtr; typedef double*** DDDPtr; void TestMacro() { DDDPtr massmatrn = new DDPtr[2]; int i,j,k; for (i = 0; i<2 ; i++) { massmatrn[i] = new DPtr[2]; } for (j = 0; j<2 ; j++) { for (k = 0; k<2 ; k++) { massmatrn[j][k] = new double[2]; } } for ( j = 0; j<2 ; j++) { for ( k = 0; k<2 ; k++) { delete [] massmatrn[j][k]; } } for (i = 0; i<2 ; i++) { delete [] massmatrn[i]; } delete [] massmatrn; } ------------------------------ cut here -------------------------- Aurelien COTTRANT wrote: > > 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