/*#define SAI_D_DebugMalloc*/
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC - Oliv' */
 
#include "SaiCPA.h"
#include "mmgSai.h"
 
/**************************************************************************/
void SAI_fn_vMemoryLogFile(void *p_vPointer,unsigned char ucAction,char *szFile,unsigned long ulLine)
{
 #if defined(_DEBUG)&& defined(SAI_D_DebugMalloc)
 static unsigned long SAI_s_ulNumberOfAllocation = 0;
 FILE *p_stFile;
 char szFileName[30];
 unsigned short uwBlocId;
 void *p_vBeginBloc;
 
 Mmg_fn_vWhereIs((void*)p_vPointer,&uwBlocId,&p_vBeginBloc);
 sprintf(szFileName,"Mem%04x.log",uwBlocId);
 if ((p_stFile = fopen(szFileName,"rt"))!=NULL) 
  fclose(p_stFile);
 else
  SAI_s_ulNumberOfAllocation = 0;
 p_stFile = fopen(szFileName,"at");
 if (p_stFile!=NULL)
 {
  if (ucAction==SAI_C_ActionMalloc) 
  {
   SAI_s_ulNumberOfAllocation++;
   fprintf(p_stFile,"Malloc  : Number=#%010d, Block=#%04x, Offset=%p (%20s,%10d)\n",SAI_s_ulNumberOfAllocation,uwBlocId,(long)p_vPointer-(long)p_vBeginBloc,szFile,ulLine);
  }
  if (ucAction==SAI_C_ActionRealloc) 
  {
   fprintf(p_stFile,"Realloc : Number=#%010d, Block=#%04x, Offset=%p (%20s,%10d)\n",SAI_s_ulNumberOfAllocation,uwBlocId,(long)p_vPointer-(long)p_vBeginBloc,szFile,ulLine);
  }
  else if (ucAction==SAI_C_ActionFree) 
  {
   SAI_s_ulNumberOfAllocation--;
   fprintf(p_stFile,"Free    : Number=#%010d, Block=#%04x, Offset=%p (%20s,%10d)\n",SAI_s_ulNumberOfAllocation,uwBlocId,(long)p_vPointer-(long)p_vBeginBloc,szFile,ulLine);
  }
  fclose(p_stFile);
 }
 
 #endif /* _DEBUG && SAI_D_DebugMalloc */
}
/**************************************************************************/

#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC - Oliv' */
