I am using Dr. Memory to debug legacy code that is crashing in certain conditions.
Dr. Memory says there is a memory leak during allocation:
float   ***in_vol=NULL;
in_vol=(float ***) malloc(inimsize[12]*sizeof(float **)); // here **
                   // inimsize is array of ints
 for (i0=0;i0<inimsize[12];i0++) {
   in_vol[i0] =(float **) malloc(inimsize[0]*sizeof(float *));
   for (i1=0;i1<inimsize[0];i1++)  {
      in_vol[i0][i1]=(float *) malloc(inimsize[1]*sizeof(float ));
   }
 }
The memory is later freed:
for (i0=0;i0<in_header[0][12];i0++) {
  for (i1=0;i1<in_header[0][0];i1++)  {
    free( (float*) *(*(in_vol+i0)+i1) );
  }
    free( (float*)  *(in_vol+i0));
}
free( (float*)in_vol); 
in_vol=NULL;
I do not see the problem, however, I am running out of memory during some tests.
Are the allocation and freeing correct?