/*#define SAI_D_DebugMalloc*/
 
#define D_SAI_Input_VariableDefine
 
#include "SaiCPA.h"
 
#include "MmgSai.h"
#include "ErmSai.h"
#include "Sai_Enum.h"
#include "Sai_str.h"
#include "Sai_Main.h"
#include "Sai_Pub.h"
#include "Sai_Priv.h"
 
/**************************************************************************/
void SAI_fn_vFirstInit()
{
 Erm_M_InitErrMsg(SAI);
 Mmg_M_InitMmg(SAI);
 Mmg_fn_cCheckAlignmentValidity();
 
#ifdef _DEBUG
 SAI_g_stInternalStructure . ulNumberOfEntries = 0;
#endif
 SAI_g_stInternalStructure . p_stFirstEntry = NULL;
 SAI_g_stInternalStructure . p_stLastEntry = NULL;
}
/**************************************************************************/
void SAI_fn_vInitFixMemory(unsigned long _ulMemSize)
{
#ifdef CHECK_MEMORY
	Mmg_M_InitSpecificBlock(SAI,E_ucSAIFixMemory, _ulMemSize, C_ulDefaultMaxNbStaticMalloc, 4, C_BlockWithFreeFlag | C_Check_AlignementFlag | C_Check_OverflowFlag);
#else /* CHECK_MEMORY */
	Mmg_M_InitSpecificBlock(SAI,E_ucSAIFixMemory, _ulMemSize, C_ulDefaultMaxNbStaticMalloc, 4, C_BlockWithoutFreeFlag | C_Check_AlignementFlag | C_Check_OverflowFlag);
#endif /* CHECK_MEMORY */
	
}
/**************************************************************************/
void SAI_fn_vInitLevelMemory(unsigned long _ulMemSize)
{
#ifdef CHECK_MEMORY
	Mmg_M_InitSpecificBlock(SAI,E_ucSAILevelMemory, _ulMemSize, C_ulDefaultMaxNbStaticMalloc, 4, C_BlockWithFreeFlag | C_Check_AlignementFlag | C_Check_OverflowFlag);
#else /* CHECK_MEMORY */
	Mmg_M_InitSpecificBlock(SAI,E_ucSAILevelMemory, _ulMemSize, C_ulDefaultMaxNbStaticMalloc, 4, C_BlockWithoutFreeFlag | C_Check_AlignementFlag | C_Check_OverflowFlag);
#endif /* CHECK_MEMORY */
}
/**************************************************************************/
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void SAI_fn_vDeleteFixMemory(void)
{
 SAI_fn_vIsolateAllListEntryByMemoryLevel(&SAI_g_stInternalStructure,E_ucSAIFixMemory);
 Mmg_M_DeleteBlock(SAI,E_ucSAIFixMemory);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
/**************************************************************************/
void SAI_fn_vDeleteLevelMemory(void)
{
 SAI_fn_vIsolateAllListEntryByMemoryLevel(&SAI_g_stInternalStructure,E_ucSAILevelMemory);
 Mmg_M_DeleteBlock(SAI,E_ucSAILevelMemory);
}
/**************************************************************************/
/* GuS 23/10/98*/
/* Same as DeleteLevelMemory, except that SAI block is not deleted.*/
/* Used in binary mode.*/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void SAI_fn_vFreeLevelMemory()
{
 SAI_fn_vIsolateAllListEntryByMemoryLevel(&SAI_g_stInternalStructure,E_ucSAILevelMemory);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
/**************************************************************************/
void SAI_fn_vSAIUseFixMemory(void)
{
 SAI_g_ucMemoryBlockUsed = E_ucSAIFixMemory;
}
/**************************************************************************/
void SAI_fn_vSAIUseLevelMemory(void)
{
 SAI_g_ucMemoryBlockUsed = E_ucSAILevelMemory;
}
/**************************************************************************/
#if !defined(RETAIL) || defined(FINAL_VERSION_FOR_TESTERS)
void SAI_PrintUsedStaticMemory(void)
{
	Mmg_M_PrintUsedStaticMemoryInModule(SAI);
}
#endif /* !defined(RETAIL) || defined(FINAL_VERSION_FOR_TESTERS) */
/**************************************************************************/
 
/**************************************************************************/
/*XB*/
#ifdef CHECK_MEMORY
void SAI_CheckMemory(void)
{
	Mmg_M_CheckMemory(SAI);
}
#endif /* CHECK_MEMORY */
/*End XB*/

/**************************************************************************/
/* XB 02/06/99 */
#ifndef FINAL_VERSION
unsigned long SAI_fn_ulGetUsedStaticMemory(void)
{
	return Mmg_M_GetUsedStaticMemory(SAI);
}
#endif /* FINAL_VERSION */
/* End XB 02/06/99 */
