/*////////////////////////////////////////////////////////////////*/ /**/ /* Interface between MRC BigFile module and the ERM and MMG modules*/ /* Yan Marchal, 97/07/21*/ /**/ /*////////////////////////////////////////////////////////////////*/ #ifndef _MACROMRC_H_ #define _MACROMRC_H_ /*////////////////////////////////////////////////////////////////*/ /**/ /* With the ERM module*/ /**/ /*////////////////////////////////////////////////////////////////*/ #include "ErrMrc.h" /* To display an error message*/ #define M_MrcError(_ucError) \ {\ Erm_M_ClearLastError(C_ucErmDefaultChannel);\ Erm_M_UpdateLastError(Mrc, C_ucErmDefaultChannel, _ucError, C_lErmNoDebugData, C_ucErmOpenInfoWindow, C_ucAllowStopForDebug, NULL);\ } /*////////////////////////////////////////////////////////////////*/ /**/ /* With the MMG module, to deal with blocks and modes of allocation*/ /**/ /*////////////////////////////////////////////////////////////////*/ #include "MmgMrc.h" /* To initialize a static block of memory*/ /* (4 entries to fill the block)*/ #define M_MrcInitBlock(_ucMode, _ulSize) \ {\ Mmg_M_InitBlock(Mrc, _ucMode, _ulSize+16);\ if (Erm_M_uwCheckError(Mmg, C_ucErmDefaultChannel)){\ M_MrcError(E_uwMrcWarningCanNotInitBlock);\ }\ } /* To reinitialize a static block of memory*/ #define M_MrcReinitBlock(_ucMode) \ {\ Mmg_M_FreeBlock(Mrc, _ucMode);\ if (Erm_M_uwCheckError(Mmg, C_ucErmDefaultChannel)){\ M_MrcError(E_uwMrcWarningCanNotFreeBlock);\ }\ } /* To delete a static block of memory*/ #define M_MrcDeleteBlock(_ucMode) \ {\ Mmg_M_DeleteBlock(Mrc, _ucMode);\ if (Erm_M_uwCheckError(Mmg, C_ucErmDefaultChannel)){\ M_MrcError(E_uwMrcWarningCanNotDeleteBlock);\ }\ } /* To know if a static block of memory is being used*/ #define M_MrcBlockIsInUse(_ucMode) \ (g_a_stMrcBlocksInfo[_ucMode].p_cBeginBlock!=NULL) /* To set the current block or mode of allocation*/ #define M_MrcSetModeAlloc(_ucMode) \ Mmg_M_SetModeAlloc4Ch(Mrc, _ucMode, C_ucMmgDefaultChannel) /*////////////////////////////////////////////////////////////////*/ /**/ /* With the MMG module, to allocate, reallocate and free memory*/ /**/ /*////////////////////////////////////////////////////////////////*/ /* To allocate memory in the current block or mode*/ #define M_MrcAllocWithoutSetMode(_xVar, _cast, _ulSize)\ {\ _xVar = (_cast) Mmg_fn_p_vAlloc4Ch(_ulSize, C_ucMmgDefaultChannel);\ if (Erm_M_uwCheckError(Mmg, C_ucErmDefaultChannel)){\ M_MrcError(E_uwMrcWarningCanNotAlloc);\ }\ } /* To allocate memory in a given block or mode*/ #define M_MrcAlloc(_ucMode, _xVar, _cast, _ulSize)\ {\ M_MrcSetModeAlloc(_ucMode);\ M_MrcAllocWithoutSetMode(_xVar, _cast, _ulSize);\ } /* To reallocate memory in the current block or mode*/ #define M_MrcReallocWithoutSetMode(_xVar, _pAdrSrc, _cast, _ulSize)\ {\ _xVar = (_cast) Mmg_fn_p_vRealloc4Ch(_pAdrSrc, _ulSize, C_ucMmgDefaultChannel);\ if (Erm_M_uwCheckError(Mmg, C_ucErmDefaultChannel)){\ M_MrcError(E_uwMrcWarningCanNotAlloc);\ }\ } /* To reallocate memory in a given block or mode*/ #define M_MrcRealloc(_ucMode, _xVar, _pAdrSrc, _cast, _ulSize)\ {\ M_MrcSetModeAlloc(_ucMode);\ M_MrcReallocWithoutSetMode(_xVar, _pAdrSrc, _cast, _ulSize);\ } /* To free memory from the current block or mode*/ #define M_MrcFreeWithoutSetMode(_pAdr) \ {\ Mmg_fn_vFree4Ch(_pAdr, C_ucMmgDefaultChannel);\ if (Erm_M_uwCheckError(Mmg, C_ucErmDefaultChannel)){\ M_MrcError(E_uwMrcWarningCanNotFree);\ }\ } /* To free memory from a given block or mode*/ #define M_MrcFree(_ucMode, _pAdr) \ {\ M_MrcSetModeAlloc(_ucMode);\ M_MrcFreeWithoutSetMode(_pAdr);\ } #endif /* _MACROMRC_H_*/