/*////////////////////*/
/* macro for Memory //*/
/*////////////////////*/
 
#ifndef __TdeMACROS_H__
 
#define M_TdeInitMem() Mmg_M_SetModeAlloc4Ch(Tde, E_ucDynamic,C_ucMmgDefaultChannel)
 
#define M_TdeAlloc(Var, cast, ulSize)\
{\
    M_TdeInitMem();\
    Var = (cast) Mmg_fn_p_vAlloc4Ch(ulSize,C_ucMmgDefaultChannel);\
    if (Erm_M_uwCheckError(Mmg, C_ucErmDefaultChannel)){\
        Erm_M_ClearLastError(C_ucErmDefaultChannel);\
        Erm_M_UpdateLastError(Tde, C_ucErmDefaultChannel, E_uwTdeWarningNotEnoughMemory, C_lErmNoDebugData, C_ucErmOpenInfoWindow, C_ucAllowStopForDebug, NULL);\
    }\
}
 
#define M_TdeAllocWithoutInitMem(Var, cast, ulSize)\
{\
    Var = (cast) Mmg_fn_p_vAlloc4Ch(ulSize,C_ucMmgDefaultChannel);\
    if (Erm_M_uwCheckError(Mmg, C_ucErmDefaultChannel)){\
        Erm_M_ClearLastError(C_ucErmDefaultChannel);\
        Erm_M_UpdateLastError(Tde, C_ucErmDefaultChannel, E_uwTdeWarningNotEnoughMemory, C_lErmNoDebugData, C_ucErmOpenInfoWindow, C_ucAllowStopForDebug, NULL);\
    }\
}
 
#define M_TdeRealloc(Var, AdrSrc, cast, ulSize)\
{\
    M_TdeInitMem();\
    Var = (cast) Mmg_fn_p_vRealloc4Ch(AdrSrc, ulSize,C_ucMmgDefaultChannel);\
    if (Erm_M_uwCheckError(Mmg, C_ucErmDefaultChannel)){\
        Erm_M_ClearLastError(C_ucErmDefaultChannel);\
        Erm_M_UpdateLastError(Tde, C_ucErmDefaultChannel, E_uwTdeWarningNotEnoughMemory, C_lErmNoDebugData, C_ucErmOpenInfoWindow, C_ucAllowStopForDebug, NULL);\
    }\
}
 
#define M_TdeReallocWithoutInitMem(Var, AdrSrc, cast, ulSize)\
{\
    Var = (cast) Mmg_fn_p_vRealloc4Ch(AdrSrc, ulSize,C_ucMmgDefaultChannel);\
    if (Erm_M_uwCheckError(Mmg, C_ucErmDefaultChannel)){\
        Erm_M_ClearLastError(C_ucErmDefaultChannel);\
        Erm_M_UpdateLastError(Tde, C_ucErmDefaultChannel, E_uwTdeWarningNotEnoughMemory, C_lErmNoDebugData, C_ucErmOpenInfoWindow, C_ucAllowStopForDebug, NULL);\
    }\
}
 
 
#define M_TdeFree(p_cAdr) \
{\
    M_TdeInitMem();\
    Mmg_fn_vFree4Ch(p_cAdr,C_ucMmgDefaultChannel);\
    if (Erm_M_uwCheckError(Mmg, C_ucErmDefaultChannel)){\
        Erm_M_ClearLastError(C_ucErmDefaultChannel);\
        Erm_M_UpdateLastError(Tde, C_ucErmDefaultChannel, E_uwTdeWarningCanNotFree, C_lErmNoDebugData, C_ucErmOpenInfoWindow, C_ucAllowStopForDebug, NULL);\
    }\
}
 
#define M_TdeFreeWithoutInitMem(p_cAdr) \
{\
    Mmg_fn_vFree4Ch(p_cAdr,C_ucMmgDefaultChannel);\
    if (Erm_M_uwCheckError(Mmg, C_ucErmDefaultChannel)){\
        Erm_M_ClearLastError(C_ucErmDefaultChannel);\
        Erm_M_UpdateLastError(Tde, C_ucErmDefaultChannel, E_uwTdeWarningCanNotFree, C_lErmNoDebugData, C_ucErmOpenInfoWindow, C_ucAllowStopForDebug, NULL);\
    }\
}
 
#endif /* __TdeMACROS_H__*/
 
