/* Releases a Modbus server channel object, previously created with  */
void TbxMbServerFree(tTbxMbServer channel)
/* Releases a Modbus server channel object, previously created with  */
void TbxMbServerFree(tTbxMbServer channel)
{
  TBX_ASSERT(channel != NULL);
  if (channel != NULL)
  {
    tTbxMbServerCtx * serverCtx = (tTbxMbServerCtx *)channel;
    TBX_ASSERT(serverCtx->type == TBX_MB_SERVER_CONTEXT_TYPE);
    TbxCriticalSectionEnter();
    serverCtx->tpCtx->channelCtx = NULL;
    serverCtx->tpCtx = NULL;
    serverCtx->type = 0U;
    serverCtx->pollFcn = NULL;
    serverCtx->processFcn = NULL;
    TbxCriticalSectionExit();
    TbxMemPoolRelease(serverCtx);
  }
}